我在服务末尾的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