Re: Problem with threads in my GTK+ application...



Dutta, Seemanta wrote:
But I would still like to know how to do this using threading.
I tried
http://research.operationaldynamics.com/blogs/andrew/software/gnome-desk
top/gtk-thread-awareness.html hoping it would solve my problem but even
that did not work :-(

It's very easy.  Whenever your thread wants to update the GUI, use the
g_idle_add() call from within the thread to ask the main loop to run
some callback function.  Then the callback function can update the GUI,
from the main thread.  Of course things like setting how far the
progress bar should go need to be done with data structures that would
be shared between the worker thread and the main thread.  If there is
ever a possibility that the main thread will also have to write to these
data structures, then you'll need to use synchronization primitives
around them.




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