I\'ve been reading up on .NET Threading and was working on some code that uses a ManualResetEvent. I have found lots of code samples on the internet. However, when reading
I've used ManualResetEvent
a lot and don't think I've ever used it inside a single method--it's always an instance field of a class. Therefore using()
often does not apply.
If you have a class instance field that is an instance of ManualResetEvent
, make your class implement IDisposable
and in your Dispose()
method call ManualResetEvent.Close()
. Then in all usages of your class, you need to use using()
or make the containing class implement IDisposable
and repeat, and repeat...