Created
May 13, 2015 03:07
-
-
Save annymsMthd/04f6f40275a4c1508d4e to your computer and use it in GitHub Desktop.
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
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