
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.55 KB | hits: 11 | expires: Never
Why does this C# ThreadPool sometimes drop work items?
class Program
{
private int x = 0;
static void Main(string[] args)
{
Program p = new Program();
int a, b;
ThreadPool.GetMaxThreads(out a, out b);
Console.WriteLine("{0} - {1}", a, b);
for (int y = 0; y < 20; y++)
{
WaitCallback cb = new WaitCallback(DoSomething);
ThreadPool.QueueUserWorkItem(cb, y);
}
}
public static void DoSomething(object state)
{
Console.WriteLine(state);
}
}