Thursday, November 28, 2013

Winform Gui Thread

You can use this extension to create simple shortcut to Invoke


public static class ControlEx
{
public static void Invoke(this Control me, Action action)
{
if (me.InvokeRequired)
{
me.Invoke(action);
}
else
{
action();
}
}
}
view raw gistfile1.txt hosted with ❤ by GitHub

Example of usage
this.Invoke(() => label1.Text = "complete");

No comments:

Post a Comment