You can use the GLib::Dispatcher class. It is a bit like a sigc::singal<void>, but works across threads. Your UI Window class should own a (or more) Dispatcher and connect handler functions. The worker thread then needs to call Dispatcher::emit() and the handler functions are executed in the UI thread.
I recommend the Dispatcher example in the docs. Regards Klaus On 03/07/2007 00:38, SIRISHA MUPPAVARAPU wrote: > Hi Klaus > > The whole scenario is like this. > > The UI is built using Gtkmm. The main method kicks off the application > by creating the UI forms and by creating the pthread objects which don't > exit the application. I store the handle (pointers) to the thread > objects and teh forms globally (using extern), so that the entire > application can access them to initiate any task. > > So, now, there is a thread which runs a task periodically (in a infinite > for loop). When this thread starts its execution, it needs to inform the > UI (GtkWindow objects created at the start of the application) that it > started running task. The UI should then display a msg window that the > application is running something. When the task is complete, the UI > should close the msg window > > What I realized is, the UI is a bunch of forms created in main method > and reside globally. On click of buttons, all I do is hide one form and > show the other. So, how is the communication possible between the > background thread and the UI GtkWindow objects. For now, I am achieving > this through global flags and timeout methods. But, thats not a clean > way of doing it. > > Any suggestions? I hope I explained the problem clearly now. > > Thanks > Sirisha > > _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
