Hi all,
Before disposing an object I'd like to know if there are other objects referencing it, because otherwise it will not be destroyed by garbage collector.
Any idea
Thanks in advace
Andrea
Hi all,
Before disposing an object I'd like to know if there are other objects referencing it, because otherwise it will not be destroyed by garbage collector.
Any idea
Thanks in advace
Andrea
Who is referencing this object?
The MATRIX
Why would you want to know if the objects being referenced by others in order to call dispose If you implement the IDisposable pattern its the responsiablity of the caller of your object to manually call Dispose on your object to free any resources held.
Regards,
Saurabh Nandu
Mike Vargas
I do use IDisposable , however each type using my object have to release my object before I complete the Dispose otherwise the object will remain attached and not begin disposed.
Also each type referencing my object has different use for the object, so as I remove the object I need to update those types.
At the moment I have 2 solutions for this problem:
1) cross referencing my object with who is using it. Which is typically used in those situation however I don't like to take care of related implications.
2) Implement an OnDisposing event for my Object, to be called during the Dispose. Which is what I use at the moment.
If .Net would provide a collection of object using my object, I would implement a simple method for each type called by my object during the Dispose.
Andrea
Jack gillespie
Hope the following link will answer you.
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbcon/html/vbconReferenceCountingGarbageCollectionObjectLifetime.asp
Thanks
Rupesh
PeterVrenken
Thank you