RE: Thread programming



i wud like 2 add something...
i had used gtk_timeout_add using this i called a function
for 1st time it worked fine & onwards it locks up...

then i used macros 
GDK_THREADS_ENTER ();

but it shud be executed only when call is from gtk_timeout_add ()
and shud not be executed when called outside

i donno y is it happening...?

-----Original Message-----
From:   Justin Hopper [mailto:gus gusalmighty com]
Sent:   Sun 6/15/2003 5:09 AM
To:     GTK+ app devel list
Cc:     
Subject:        Thread programming

I'm new to thread programming, but necessity calls for threads in the
application I'm writing, so I've started learning how to use them.

The main problem I'm running into now is that when a looping thread
tries to update a label in the GUI, the main thread seems to lock up. 
I'm sure I'm missing something basic, probably need to lock something. 
But basically, here is what I'm doing:

// main.c 
...
g_thread_init(NULL);
...
pthread_create(&check_tid, NULL, check_queues, window1);
... 
gdk_threads_enter();
gtk_main ();
gdk_threads_leave();


// check_queues.c
    while (1) {
        ...(check some mysql database for data)...
        gdk_threads_enter();
        label = lookup_widget(GTK_WIDGET(toplevel),"label_name");
        gtk_label_set_text(GTK_LABEL(label), "whatever");
        gdk_threads_leave();
    }


The GUI responds normally until the second cycle of the above
check_queues function.  When the label is set the second time, the GUI
locks up.

I've read the FAQ on thread programming, but I must be missing something
fundamental on how they work.

Any help is greatly appreciated.

-- 
Justin Hopper <gus gusalmighty com>

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






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