我正在进行一些多线程操作,并使用AutoResetEvents和ManualResetEvents来控制我的主循环。当“销毁”线程时,我也必须处理这些信号,这很清楚。
但是我看到了不同的处理Waithandles的方法,我不确定哪个是正确的:
版本1
if (disposing)
{
this.threadExitEvent.SafeWaitHandle.Dispose();
this.threadExitEvent.Close();
this.threadExitEvent = null;
....
}
版本2
if (disposing)
{
this.threadExitEvent.Close();
this.threadExitEvent = null;
....
}
第三版
if (disposing)
{
this.threadExitEvent.Close();
....
}