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

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Apr 26 15:53:28 EDT 2009


On Sun, Apr 26, 2009 at 3:29 PM, Piotr Budny <piotr.budny at gmail.com> wrote:
> Hello,
> for all, who don't want to download external code, here's the simplest one.
> It still randomly SIGSEGVs.
...
>                        Sig.Changed += new ChangedEventHandler(this.OnChanged);
..
>                protected void OnChanged(string s)
>                {
>                        Random r = new Random();
>                        l.Text = String.Format("blah blah: {0}, {1}", r.Next(), s);
>                        l.ModifyBg (Gtk.StateType.Normal, new Gdk.Color ((byte)r.Next(),
> (byte)r.Next(),(byte) r.Next()));

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.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Gtk-sharp-list mailing list