如何检查 AutoResetEvent
对象是通过超时还是通过从另一方法调用 Set()
触发的?
这是我的代码:
private AutoResetEvent autoResetEvent = new AutoResetEvent(false);
private int timeout = 30000;
public void SyncMethod()
{
// some code before
autoResetEvent.WaitOne(timeout);
// if autoResetEvent called by timeout then { do some stuff }
// some code after
}
public void AsyncMethod()
{
// some code before
// ok I am done
autoResetEvent.Set();
}