Re: Thread communication



On Tue, 2002-02-12 at 17:39, Lennartsson, Andreas wrote:
Hi,

I am using Gtk 1.2. My application main and a communication thread. I spawn
the communication thread just before I call gtk_main. My idea was to emit a
emit a signal int the communication thread, using gtk_signal_emit_by_name.
My GUI is set up to call the appropriate callback routine. 
This works just fine, the callback routine gets called, but the pid for the
callback routine is the same as the pid for the communications thread. I
would have expected that the pid for the callback routine would be the same
as the gtk_main? The fact that the callback routine has a different pid than
gtk_main stops me from performing my tasks in the callback routine. Is there
a way to cause gtk_main to call a callback routine (so the call back has the
same pid as gtk_main) from code (like the callbacks are called on user
input).

  I think you need to have your thread communicate with the main thread
so that you emit the signal in the main thread.  One way to accomplish
this would be (for example) to create a pipe and write to it from the
communication thread. The main thread would monitor this pipe with
gtk_input_add and, when data arrives, read it (to empty the pipe's
buffer) and then emit the signal.


Thanks,

Andreas.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Gustavo João Alves Marques Carneiro
<gjc inescporto pt> <gustavo users sourceforge net>



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