Is anywhere book or g开发者_Go百科ood manual, but better book about GTK+/glib, and multithreading in C/GTK+? I need to run a function in another thread than main window, and make it cancellable.
GCancellable is part of the GIO I/O library. It provides a thread-safe way to simply send a "cancel yourself" message, and should be easy to implement in a thread of your own.
Simply create an instance of GCancellable using g_cancelablle_new()
, and then either poll it periodically (using g_cancellable_is_cancelled()
) in your thread, or use the signal support.
Not recommended. glib uses an event loop, so do your processing in slices via g_timeout_*()
or g_idle_*()
, and just stop processing when you want to cancel it.
精彩评论