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
}
}

Comments

Popular posts from this blog

Parse XML to dynamic object in C#

C# Crop white space from around the image