Re: When, why and where should a struct be used?
- From: Sericinus hunter <serhunt@xxxxxxxxx>
- Date: Sun, 30 Apr 2006 15:13:38 GMT
Bruce Wood wrote:
....
Well, yes, but there's another way that the Dispose method is called,
and that's by the garbage collector just before it reclaims an object.
So, it's not _entirely_ necessary that Dispose be called on an object
before it goes out of scope... it's just better practice because it
releases unmanaged resources sooner. (At least, that's my
understanding... someone please correct me if I'm wrong.)
Is it not Finalize method which is called by GC? To my understanding
(which can also be wrong indeed), GC does not call Dispose, so this is
still necessary to call it somehow. Normally, the call to Dispose is
placed in the object destructor for exactly this very reason: if it
was not called directly, like with 'using', it is guaranteed that it
will be called during garbage collection.
.
- Follow-Ups:
- Re: When, why and where should a struct be used?
- From: Chris Chilvers
- Re: When, why and where should a struct be used?
- From: Barry Kelly
- Re: When, why and where should a struct be used?
- References:
- When, why and where should a struct be used?
- From: clintonG
- Re: When, why and where should a struct be used?
- From: randolpho@xxxxxxxxx
- Re: When, why and where should a struct be used?
- From: Bruce Wood
- When, why and where should a struct be used?
- Prev by Date: Synchronized Collection<T> Recommendation
- Next by Date: Re: Synchronized Collection<T> Recommendation
- Previous by thread: Re: When, why and where should a struct be used?
- Next by thread: Re: When, why and where should a struct be used?
- Index(es):
Relevant Pages
|