Observe the following pseudo:
ManualResetEvent[] resetEvents = new ManualResetEvent[operations.Count];
for( int i = 0; i < operations.Count; i++ )
{
resetEvents[i] = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(new WaitCallback(timeConsumingOpHandler), resetEvents[i]);
}
WaitHandle.WaitAll(resetEvents);
In the case that an exception occurs inside one of the pooled threads, my ASP.NET WebApp is deadlocking. No exception information is being passed on the response stream. I'm seeking suggestions to prevent this. A fixed timeout is acceptable. Assume that the timeConsumingOpHandler Set()s the WaitHandle.
The entire timeConsumingOpHandler is wrapped in a try-catch-finally block where the WaitHandle is Set() during the finally section. None the less, deadlock occurs.