8
是否可以检查AutoResetEvent
实际对象的处理方式?它是通过超时还是通过从另一个方法调用Set()来触发的?检查AutoResetEvent状态
这是我的代码。
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();
}
太容易了。 :) 谢谢! – 2012-07-17 08:13:08