[Gtk-sharp-list] Updating UI from a thread
Vincent Arnoux
vincent.arnoux@rfo.atmel.com
Tue, 08 Mar 2005 20:33:06 +0100
Hello,
I start a large computation in a thread of my program, and I want this
thread to update a label. I know this looks like a classical issue, but
I can't find an easy solution. Can you please give me a solution, or
point me towards a link ?
class myApp
{
Label myLabel;
public static void Main (string[] args)
{
new myApp ();
}
public myApp()
{
//build a Gtk# window an add a label called myLabel
Thread oThread = new Thread(this.LongComputation);
oThread.IsBackground = true;
oThread.Start();
}
public void LongComputation()
{
for (int i = 0; i < 100000000000000; i++)
myLabel.Text = "#" + i;
}
}
Regards,
Vincent