Skip to content

Instantly share code, notes, and snippets.

@annymsMthd
Created May 13, 2015 03:07
Show Gist options
  • Save annymsMthd/04f6f40275a4c1508d4e to your computer and use it in GitHub Desktop.
Save annymsMthd/04f6f40275a4c1508d4e to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ThreadPoolTest
{
class Program
{
static void Main(string[] args)
{
Console.ReadLine();
for (var a = 0; a < 1000; a++)
{
for (var i = 0; i < 10000; i++)
{
Task
.Delay(TimeSpan.FromMilliseconds(1))
.ContinueWith(_ =>
{
Thread.Sleep(1000);
}, TaskScheduler.Current);
}
int worker;
int completion;
ThreadPool.GetAvailableThreads(out worker, out completion);
Console.WriteLine("{0} workers, {1} completion", worker, completion);
}
Console.WriteLine("done");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment