Re: [Vala] Idle.add lambda function with local variable



On Sun, Dec 27, 2009 at 09:58:52 -0800, Geert Jan wrote:
Ok I messed up that example, sorry. Obviously in my real project I do
create a main loop. Don't have time now, but unless someone can help me
despite my bad example I'll post the real code from my project later.

Well, the point is not whether the main loop is created, but whether it's
actually dispatching. If you call the Thread.usleep() from within a main loop,
no idle handlers are going to run, because you didn't return to the main
loop, so it can't do it's job. You have to return from the currently
executing handler and than the idle handlers can run (the event dispatching
is completely synchronous -- until one is completely handled, no other can
be).

Newer vala (since 0.7.7 IIRC) allows writing a single "async" function, that
will be automatically split into parts that can be run from the mainloop at
separate events, but you need to understand how the main loop behaves before
you can use them anyway.

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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