tags:

views:

19

answers:

2

Is anywhere book or good 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.

A: 

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.

Ignacio Vazquez-Abrams
+1  A: 

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.

unwind