I'm calling Thread.Join on a ThreadPool thread at the end of a service. The code executed in the thread ends about the same time as Thread.Join is called, but the Join takes 2 minutes to return. Why is it taking 2 minutes for Thread.Join to return.
The log:
(2009-10-08 14:22:09) Inf: ProcessRequests - Interrupted, exiting.
(2009-10-08 14:22:09) Dbg: ProcessingDriver.Stop - Waiting on thread to exit.
(2009-10-08 14:24:10) Dbg: ProcessingDriver.Stop - Thread joined.
The code:
WaitHandle.Set(); //Signal it's time to go home
LogManager.Logger.WriteLog(LOG_SOURCE, "Waiting on thread to exit.", LogType.Debug, 7);
ProcessingThread.Join(); //Wait for the thread to go home
LogManager.Logger.WriteLog(LOG_SOURCE, "Thread joined.", LogType.Debug, 7);