Skip to content

Instantly share code, notes, and snippets.

@mpj
Created May 7, 2010 13:52
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 mpj/393445 to your computer and use it in GitHub Desktop.
Save mpj/393445 to your computer and use it in GitHub Desktop.
delegate void SetTextCallback(Control ctrl, string value);
void SetControlText(Control ctrl, string value)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (ctrl.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetControlText);
this.Invoke(d, new object[] { ctrl, value });
//d.Invoke(lbl, txt);
//this.Invoke(d, new object[] { text });
}
else
{
ctrl.Text = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment