Web lists-archives.com

Re: gtk-main-iteration -- use and understanding




On Sun, Jan 31, 2016 at 8:10 AM, Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
Do you know an not too complicated
example where code in a callback is called which may block for about
one second? In the long term I may switch to a asyncroneously design,
but currently I have no idea how to do that best. Have you a hint for
that approach?

My first thought would have been to trigger that callback via a g_idle_add() [1] call. This will schedule the callback to run only when there are no more pressing events waiting. Thus, the main_loop can finish handling input events and updating the screen before starting your callback. The callback will still block while it's running, of course, but that sounds like it's okay for your purposes at the present.

Note that, if the callback returns True, it will be called again at the next idle time. If your callback is looping, your may be able to use this to call each loop separately, letting the main loop handle events in between. I don't know what this would mean for performance, though.

Robert

[1] https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-idle-add

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list