Re: Thread communication



Hi Andreas,

A technique that seems to work for me (although I'm not sure if that's by
luck rather than design) is for the "other" thread to use g_idle_add() to
schedule a function to be run by the main thread when it next gets a chance.
Then the function will have the pid of your main thread rather than the
thread that scheduled it.  The function should return FALSE so it isn't
called repeatedly.

Obviously it relies on there being some "idle" time in your main loop.

Hope that helps,
Richard.

----- Original Message -----
From: "Lennartsson, Andreas" <alennartsson ICTV com>
To: <gtk-app-devel-list gnome org>
Sent: Tuesday, February 12, 2002 5:39 PM
Subject: Thread communication


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).

Thanks,

Andreas.
_______________________________________________
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]