I'm struggling to understand why nothing is output using the following:
class Program
{
static int m_Active = 500;
static void Main(string[] args)
{
ThreadPool.SetMaxThreads(5, 5);
Enumerable.Range(1, m_Active).ToList<int>()
.ForEach(i => ThreadPool.QueueUserWorkItem((o) => { DoWork(i); }));
}
private static void DoWork(int i)
{
new Action(() => { Console.WriteLine(i); }).Invoke();
if (Interlocked.Decrement(ref m_Active).Equals(0))
new Action(() => { Console.WriteLine("Done"); }).Invoke();
}
}