Re: Gtk and Threads...
- From: Brad House <brad mainstreetsoftworks com>
- To: Dany Mezher <Dany Mezher irisa fr>, gtk-app-devel-list gnome org
- Subject: Re: Gtk and Threads...
- Date: Thu, 23 Aug 2001 07:51:25 -0400
Well, communicating between threads is generally simple. Set a
variable or something like
int write_graph=0;
and set it to 1 when you want the other thread to update it's graph.
Then set it back to 0 when the thread is done writing the graph.
Now where you're probably getting confused is here. You won't
have 2 processes, you'll have 3.
1) Main process that runs gtk_main();
2) Computation thread
3) drawing thread.
You'll need to make sure you do a
g_thread_init(NULL); before your call to gtk_init
Then to call gtk_main() do this:
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
Finally,
in your drawing thread, you'll need to call gdk_threads_enter()
before you draw, and gdk_threads_leave() after. Make sure you
do this! Also, you may have to call gdk_flush() before you call
gdk_threads_leave().
I hopw this helps.
-Brad
Dany Mezher wrote:
Hello,
I am writing a numerical application using GTK. I have two threads
in my application; one to do the comutations and the other to do the
graphics and I want to plot the computed values on the fly. How can the
computation thread tell the graphics thread that it can do some graphs??
Regards
Dany
_______________________________________________
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]