Wednesday, 10 December 2008

C# Updating GUI from different thread

void MyEventHandler(object sender, EventArgs e)
{
if (this.InvokeRequired)
{
this.Invoke(new EventHandler(MyEventHandler), new object[] { sender, e }
);
}else{
//update GUI here
}
}
void MyEventHandler(object sender, MyEventArgs e)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new EventHandler<MyEventArgs>(MyEventHandler), new object[] { sender, e });
}
else
{
//update GUI here
}
}

No comments:

Post a Comment