> Ok thank you. Indeed I learned the hard way that that calling
> a function
>   (even through a pointer) from a thread is executed in that thread's
> context (although I couldn't word it so nice ;) ), and I should have
> known that it works that way if I had thought it over :) In
> Gtk there is
> a way to let the main loop handle a function in the context
> of the main
> program (g_idle_add() for the completeness of the archive)
> but I haven't
> found a portable solution yet.

Unfortunately I have never use Gtk, so can't comment on g_idle_add().

> The problem with the user-defined message is ofcourse that it needs a
> HWND, which is very specific for windows. I have solved other (win32)
> threading problems this way, and it worked fine - but cross-platform
> threading seems to be a hard problem.
> Anyway, I'll go ask around on a couple of pthreads mailing
> lists about
> it. Thanks everybody for your input.

You can send a 'window' message, but what I meant was a 'thread message'
(a message associated with a thread, instead of one window).  You post
such a message using PostThreadMessage( ).  This requires you be aware
of the target thread's ID, and this doesn't make it impossible to port
to other platforms, since I can't think of any hypothetical platform
which 'knows' which thread you mean without you specifying some kind of
an ID.  :-)

Let us know if there's more you need to know.

Ehsan




Reply via email to