Re: Is there a way to make this work?



what is in timeout_handler2 ?

every "timeout" you want to reperse
your xml and rebuild your CList (or something
close to that). if you call gtk_clist_* from
your timeout_handler2() function than your
missing the point. 

the point beeing:
    But you could do a number of things. just remember
that only one thread is allowed to update the GUI.

glib is thread aware. gtk is not thread safe.
use threads to do long batch jobs while using
your _main_ thread (the one containing gtk_main() )
to update the gui and do _short_ jobs. 

hijacking the gtk main loop will freeze the gui.
updating the gui from threads creates potential 
race conditions.

        -Tristan

here is some pseudo code to make things clearer.
(remember you'll need a method to know when
you should call g_thead_join())


/********** in child thread **************/
timeout_handler2()
{
        while (still_stuff_to_do) {
                do stuff;
                write result data to a communication channel;
        }
}


/********** in parent thread ***********/

create io channel;
spawn timeout_handler2;
g_io_channel_add_watch(channel...);


channel_io_cb() {
        read data;
        update CList with data read;

}



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