[Gtk-sharp-list] Changing widgets visual properties (wiewport backgrounds, labels) bug
Piotr Budny
piotr.budny at gmail.com
Sun Apr 26 15:29:35 EDT 2009
Hello,
for all, who don't want to download external code, here's the simplest one.
It still randomly SIGSEGVs.
using System;
using System.Threading;
using Gtk;
namespace testbg
{
class MainClass
{
public static void Main (string[] args)
{
Application.Init ();
MainWindow win = new MainWindow ();
win.Show ();
Sig s = new Sig();
Application.Run ();
}
}
public class MainWindow : Gtk.Window
{
Label l;
public MainWindow (): base(Gtk.WindowType.Toplevel)
{
l = new Label();
l.Text = "asd dsaas dsa jkhdas ";
Sig.Changed += new ChangedEventHandler(this.OnChanged);
this.Add(l);
ShowAll();
}
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()));
}
}
public delegate void ChangedEventHandler(string test);
public class Sig
{
public static event ChangedEventHandler Changed;
public Sig()
{
Thread t = new Thread(new ThreadStart(ThreadProc));
t.Start();
}
protected virtual void ThreadProc()
{
while(true)
{
Thread.Sleep(50);
if (Changed != null)
Changed("u");
}
}
}
}
Regards,
Piotr Budny
More information about the Gtk-sharp-list
mailing list