Re: Work woth GUI from a thread that was made by pthread_createfunction



"bharat  tewari" <bharat tewari wipro com> writes:

or one of the solution is to make all the ui being handled by one thread
either through mutex synchronization etc.

If you must use threads, then the solution is indeed to serialise all
access to gdk/gtk+ though the thread that runs the main loop. Any time
you want to call a gdk or gtk function from a thread, do

   g_idle_add (function_that_does_it, data_for_function);

the function_that_does_it() can safely call any gdk and gtk+
functions. 

(Make sure that that function doesn't block. Ideally it shouldn't run
for more than a few milliseconds; it can return TRUE to have the main
loop call it again when all events have been processed).



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