Re: GTK+ & GLib threads

You should not use any GUI calls in your background thread. It would be better to use something like GAsyncQueue, in combination with a timeout function, to send notification to the GUI thread, that it should update itself in someway. You might find it very useful to search through the archives of this mailing list, as this topic has come up quiet often.


Andrew Kirillov wrote:


I am writing a multithreaded application. There are two threads:
1) default thread for GUI and 2) a background thread, which downloads
something from network. Sometimes I need to update some widgets
depending on current state of the background thread. I am using a call
to gtk_widget_queue_draw() from the background thread. Then the widget
must receive the expose event and to draw something in the main
thread. All works fine, but not so long. After some time the widget
does not receive expose event any more. The background work performs
as before, but the call to my callback for expose event does not
occur. More of it - some widgets, menu for example, are not updated
after it.

What happens ? Any ideas ?
What is a safe method to invalidate some widgets from a background
thread ?

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