[Gtk-sharp-list] Changing widgets visual properties (wiewport backgrounds, labels) bug

Piotr Budny piotr.budny at gmail.com
Mon Apr 27 05:55:45 EDT 2009

Dnia niedziela, 26 kwietnia 2009, Michael Hutchinson napisał:
> GTK+ isn't threadsafe; you can't safely touch GTK objects from other
> threads. There are a few ways to handle timers and calls from other
> threads:
> Gtk.Application.Invoke
> GLib.Timeout.Add
> GLib.Idle.Add
> See http://mono-project.com/Responsive_Applications for more info.

I've read this topic, but didn't realize, that signal received within the 
Gtk.Application isn't thread safe.
The easiest way was (as I suppose) is:

if(Changed != null)
	Gtk.Application.Invoke(delegate { Changed("u"); });

or catch the signal in MainWindow.OnChanged() and execute second function (or 
code) with G.A.Invoke.

The second approach is, as I think, more correct, because it does not make 
Thread class Gtk dependent. The first is "write and forget" - You don't have to 
remember about G.A.Invoke and writing delegates.


More information about the Gtk-sharp-list mailing list