Re: Pthreads messes up interface

>//(this is gtk_main pthread)
>pthread_t my_new_thread;
>void start_auto(GtkToggleButton  *tb, gpointer ud){
>  pthread_create(&my_new_thread, NULL, auto_update, 
>void auto_update(){
>  while(var == 1){ //variable will be changed from other
>                   //pthread.
>     do_stuff(); //stuff will emitt signals that
>                 //affect user interface in
>                 //gtk_main pthread.
>     sleep(1);
>  }

1) Read the FAQ at

2) when you emit signals, do the handlers make GTK+ calls?

   if so, you need to use the GDK_THREAD_ENTER/LEAVE paradigm, or
   redesign your application so that my_new_thread never calls GTK or GDK
   or Xlib.


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