Gra*_*amS 21 .net c# multithreading synchronization
如果我使用EventWaitHandle
(或AutoResetEvent
,ManualResetEvent
)来同步线程之间然后做我需要调用Close()
或Dispose()
方法对事件处理的时候,我用它做什么?
EventWaitHandle
继承自WaitHandle
,实现IDisposable
.如果我没有IDisposable
在包含任何类的任何类上实现,FxCop会抱怨EventWaitHandle
.所以这表明我确实需要打电话给它.
但是,这些MSDN用法示例都没有调用Dispose()
或Close()
:
http://msdn.microsoft.com/en-us/library/system.threading.eventwaithandle(VS.80).aspx http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent( VS.80).aspx http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent(VS.80).aspx
这只是微软无视自己建议的一个例子吗?