Created
September 18, 2012 22:33
-
-
Save naraga/3746398 to your computer and use it in GitHub Desktop.
Long running task effect on threads allocation
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
class Program | |
{ | |
// TaskCreationOptions.LongRunning - demo | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("press any key when ready (run ProccessExplorer 's proccess Threads tab)"); | |
Console.ReadLine(); | |
for (int i = 0; i < 1000; i++) | |
{ | |
int i1 = i; | |
Task.Factory.StartNew(() => | |
{ | |
Thread.Sleep(1000); | |
Console.WriteLine(i1); | |
}, TaskCreationOptions.LongRunning); | |
} | |
Console.WriteLine("*************** press any key to finish ******************"); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment