Skip to content

Instantly share code, notes, and snippets.

@Immerseit
Created April 23, 2012 07:04
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 Immerseit/2469286 to your computer and use it in GitHub Desktop.
Save Immerseit/2469286 to your computer and use it in GitHub Desktop.
Do button blick as Callback
public class OneClickButton : Button
{
protected override void OnClick(EventArgs e)
{
this.Enabled = false;
PerformAsync(CallBack);
base.OnClick(e);
}
void CallBack()
{
this.Enabled = true;
}
void PerformAsync(Action callBack)
{
ThreadPool.QueueUserWorkItem(this.Worker, callBack);
}
void Worker(object callBack)
{
try
{
//
}
finally
{
((Action)callBack)();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment