I have the following code...
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Method));
}
}
// This thread procedure performs the task.
static void Method(Object stateInfo)
{
//do some work
}
}
My question is the main thread exits before the threadpool task gets a chance to run, How do i over come this? I have looked at MSDN and they say use Thread.Sleep(), does anyone have a more elegant solution.
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Method));
}
}
// This thread procedure performs the task.
static void Method(Object stateInfo)
{
//do some work
}
}
My question is the main thread exits before the threadpool task gets a chance to run, How do i over come this? I have looked at MSDN and they say use Thread.Sleep(), does anyone have a more elegant solution.