私はいくつかのマルチスレッドを行っており、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;
....
}
バージョン 3
if (disposing)
{
this.threadExitEvent.Close();
....
}