ReaderWriterLockSlim + Dispose?



One last question today :) Most locks I've used never had a Dispose
(Monitor, ReaderWriterLock, etc). Looking at the
ReaderWriterLockSlim's Dispose method its just cleaning up some
Threading.WaitHandle's.

Whenever I see a Dispose method I always want to call it after I'm
done with the object. All examples I've ever found online don't use
dispose with the ReaderWriterLockSlim. Making my classes that use
this lock IDisposable for this reasion alone is a little frustrating,
and makes the implementation a little harder (since I have to
constantly check to see if the locks disposed, mainly when using it
with a thread pool).

Since only WaitHandles are getting closed, the GC will eventually
clean them if I ignore the Disposing on the ReaderWriterLockSlim? Is
there performance increases in using the disposable WaitHandles vs how
other locks without Dispose() do it?

Thanks :) I'm mostly just curious.

NB
.



Relevant Pages

  • Re: ReaderWriterLockSlim + Dispose?
    ... "definally dispose when your done". ... potential problem here, but its not like WaitHandles are images, no ... if your sychronizing a thread pool ... How many ways can there be for locks to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deterministic Collection Using Generics
    ... I moved the disposed clause inside the locks. ... And yes, Generics are cool. ... is with the Dispose method and the checks at the beginning of Add, ... and Invoke to see if the object has been disposed. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A (not so) basic question.
    ... Calling Dispose, does not 'Dispose of the Font object', it allows the font ... It is not normally necessary to call the dispose method for an object ... object to 'clean up' 'unmanaged resources' in advance of it being GC'ed. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Destroy Objects How ?
    ... you are not required to assign Nothing to an object to 'destroy' it. ... Some classes expose a Dispose method. ... For such objects you need to call the Dispose method of the object rather ... That said, you are free to explicity 'destroy' objects, a'la VB6, if you so ...
    (microsoft.public.dotnet.languages.vb)
  • Re: destructor not being called
    ... should leave temp files lying around if you don't need them. ... You don't have to do any memory management when implementing IDisposable ... section of the MSDN documentation titled "Implementing a Dispose Method", ...
    (microsoft.public.dotnet.languages.csharp)

Loading