V
Vai2000
I have a situation in which threads are spawned for jobs. I am using the
ThreadPool Class to invoke the delegate.
Problem is my calling class exits out before the Threads have completed
their job so I am running into problem. What should I do to prevent it or
find a better way. Since I HAVE to use the ThreadPool class with
QueueUserWorkItem method I don't have alternatives. I don't want the calling
thread to Sleep.
kindly help
TIA
// ========= CODE =================
int main()
{
Console.WriteLine("Started");
ThreadPool.QueueUserWorkItem(new WaitCallback(FlushOff),
dataBuffer.ToString());
Console.WriteLine("Finished");
return 0;
}
void FlushOff(object key)
{
lock{
// something
}
}
ThreadPool Class to invoke the delegate.
Problem is my calling class exits out before the Threads have completed
their job so I am running into problem. What should I do to prevent it or
find a better way. Since I HAVE to use the ThreadPool class with
QueueUserWorkItem method I don't have alternatives. I don't want the calling
thread to Sleep.
kindly help
TIA
// ========= CODE =================
int main()
{
Console.WriteLine("Started");
ThreadPool.QueueUserWorkItem(new WaitCallback(FlushOff),
dataBuffer.ToString());
Console.WriteLine("Finished");
return 0;
}
void FlushOff(object key)
{
lock{
// something
}
}