If I am using EventWaitHandle
(or AutoResetEvent
, ManualResetEvent
) to synchronise between threads then do I need to call the Close()
or Dispose()
methods on that event handle when I am done with it?
EventWaitHandle
inherits from WaitHandle
, which implements IDisposable
. And FxCop complains if I don't implement IDisposable
on any class that contains an EventWaitHandle
. So this suggests that I do need to call it.
However none of these MSDN usage examples call Dispose()
or 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
Is this just an example of Microsoft ignoring their own advice?