Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created June 5, 2014 07:29
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 andrijac/f3379f3cd126e87ebcd8 to your computer and use it in GitHub Desktop.
Save andrijac/f3379f3cd126e87ebcd8 to your computer and use it in GitHub Desktop.
C# Threading
// http://stackoverflow.com/a/363409/84852
System.Threading.ThreadPool.QueueUserWorkItem(delegate {
DoSomethingThatDoesntInvolveAControl();
}, null);
// http://stackoverflow.com/a/661662/84852
///...blah blah updating files
string newText = "abc"; // running on worker thread
this.Invoke((MethodInvoker)delegate {
someLabel.Text = newText; // runs on UI thread
});
///...blah blah more updating files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment