Re: [Vala] How to get return values from async methods



I guess the way I would think of it is, the closure is when you get the results from the async method.  The 
appropriate way to deliver those results to others depends on who they are.  The ideas you tossed out all 
make sense, but which one to use is situational.

-- Jim

On Wed, Oct 17, 2012 at 1:45 PM, tomw <tomw ubilix com> wrote:
On Mi, 2012-10-17 at 20:26 -0007, Jim Nelson wrote: 
Yes, your closure isn't being called until some time after 
get_results() returns. 


Remember, async works with the event loop. A good way to think of it 
is like this: some_async_method.begin() doesn't call the method, 
rather .begin schedules the method on the event loop for later 
execution. (This is technically not true, some code in 
some_async_method() may be executed immediately, but in my experience 
thinking of it as being scheduled is the safest way to code async in 
Vala.) 

Thanks, Jim, 
So, the only way to get some return values from async methods would be 
to either issue a signal from within the closure, passing the result or 
to register a callback instead of the closure, right? 

br, 

-- 
tomw 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]