Created
May 14, 2012 20:33
-
-
Save cbcwebdev/2696613 to your computer and use it in GitHub Desktop.
Task Parallel Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class AwesomeSauceForm : Form | |
{ | |
private Task _theTaskAtHand; | |
public AwesomeSauceForm() | |
{ | |
InitializeComponent(); | |
Task.Factory.StartNew(() => | |
{ | |
// Do some work if needed, like load data before the function loads, etc. | |
// This will happen in the thread pool, off the UI thread | |
Thread.Sleep(1000); | |
// Begin working with the UI | |
_theTaskAtHand.Start(); | |
}); | |
// check out MSDN to see what you have access in terms of parameters, I think they can dispatch quite a bit of info to you | |
_theTaskAtHand = new Task((paramsIfNeeded) => { | |
textBox1.Text = "From child task"; | |
}, TaskScheduler.FromCurrentSynchronizationContext()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment