Skip to content

Instantly share code, notes, and snippets.

@snargledorf
Created July 26, 2013 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snargledorf/6090313 to your computer and use it in GitHub Desktop.
Save snargledorf/6090313 to your computer and use it in GitHub Desktop.
This is an extension method for the Windows Form class that mimics the behavior of Androids Activity.runOnUiThread(Runnable) method.
public static class RunOnUiThreadExtensionMethod
{
public static void RunOnUiThread(this Form @this, Action action)
{
if (@this.InvokeRequired)
{
@this.BeginInvoke(action);
}
else
{
action();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment