[Gtk-sharp-list] Gtk.DrawingArea not thread-agnostic on Win32?

Sam Hocevar sam at zoy.org
Tue Sep 23 09:49:16 EDT 2008


On Tue, Sep 23, 2008, Adam Tauno Williams wrote:

> > I have a threaded GTK# application that creates widgets in several
> > threads (all with proper synchronisation, of course). It works
> > perfectly
> > on Linux, but it hangs on Win32 when using Gtk.DrawingArea objects.
> 
> Yep, it is well documented that what you describe won't work.

   Okay, I have never cared much about Win32 portability until recently,
so I missed these few places where this is mentioned in the GTK
documentation.

> Management of the UI must all be done from the main thread.  I use
> Application.Invoke(delegate{ }) to modify the UI from [potentially]
> other threads.

   The reason I am doing this is that I have both a GTK loop and an
OpenGL loop, in two separate threads, because merging them makes the GTK
interface sluggish when rendering complex scenes.

   I use the GtkGlArea widget, which is basically a DrawingArea with
an embedded GL context. Because of a history of OpenGL drivers using
thread-local storage and failing with multithreading, I wanted the GL
context to be created in the "GL thread", which is why I do not create
the GtkGlArea object in the main thread.

   I guess I'll either hack gtkglarea, or make sure I only use thread-
safe OpenGL drivers on Windows.

Regards,
-- 
Sam.


More information about the Gtk-sharp-list mailing list