Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst <nvrbst@xxxxxxxxx>
- Date: Tue, 8 Apr 2008 14:50:25 -0700 (PDT)
In the former case, the initial implementation is quick, but then you
create a situation in which you can't tell whether you're catching an
expected exception or one that represents some other bug.
Your catching a very specific exception "Object null exception", other
exceptions wont be caught.
But at the very least you've now committed to a
huge amount of work to wrap every single one of your uses of a disposable
object in a try/catch handler.
It's a lock object... you grab it once and release it shortly after,
probably 75%+ of the time.
Furthermore, if you implement it this way, then users have a lot
easier time using the object. They simply call ".Dispose()" when they
are done with it (little more effort in the design I agree to ensure
proper clean up in all situations). The other solutions put more
effort in different parts of the project (IE clean up methods, thread
stoping. Putting logic like this in the dispose would world very
well), which basically pushes the responsablity onto the user of the
class because you don't want to harder maintance.
In my eyes, maintainence is as simple, it intuativly becomes 'thread
safe', and easier for others to use. Weighed against your "harder to
maintain even with good commenting". It's not a replacment, they both
have different pros and cons. Surly you should be able to see that...
NB
.
- Follow-Ups:
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- References:
- ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- Re: ReaderWriterLockSlim + Dispose?
- From: NvrBst
- Re: ReaderWriterLockSlim + Dispose?
- From: Peter Duniho
- ReaderWriterLockSlim + Dispose?
- Prev by Date: Re: Design: Custom Exception Usage
- Next by Date: Re: ReaderWriterLockSlim + Dispose?
- Previous by thread: Re: ReaderWriterLockSlim + Dispose?
- Next by thread: Re: ReaderWriterLockSlim + Dispose?
- Index(es):
Relevant Pages
|
Loading