Skip to content

Instantly share code, notes, and snippets.

@naraga
Created September 18, 2012 22:33
Show Gist options
  • Save naraga/3746398 to your computer and use it in GitHub Desktop.
Save naraga/3746398 to your computer and use it in GitHub Desktop.
Long running task effect on threads allocation
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