我在服務末尾的ThreadPool線程上調用Thread.Join。線程中執行的代碼與Thread.Join被調用的時間大致相同,但Join需要2分鐘才能返回。爲什麼Thread.Join需要2分鐘才能返回。爲什麼Thread.Join需要很長時間才能返回?
日誌:
(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.
代碼:
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);
因爲我爲一個核心進程使用了ThreadPool線程。 – 2009-10-08 18:54:32