我在 ManualResetEvent 的一个实例上调用 Set 方法,它偶尔会死锁。我在文档中找不到任何内容表明这是一种阻塞方法。什么可能导致 MRE.Set 阻塞?
堆栈跟踪:
[Managed to Native Transition]
mscorlib.dll!System.Threading.EventWaitHandle.Set() + 0xe bytes
MyCode.StopAll(bool force) Line 179 + 0xd bytes
MyCode.CalcCheckThread() Line 250 + 0xb bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
private static void StopAll(bool force)
{
if( !force )
LogHelper.SendAllCloseState(logger);
_forcablyExit = force;
_running = false;
_stopWait.Set(); // This line appears to be blocking
}