Ufff, references and disposing problem

  • Thread starter Thread starter Martin Zugec
  • Start date Start date
M

Martin Zugec

Hi guys,

I have project where few classes are interacting with each other...
Problem is that I probably still dont fully understand object life-
cycle in .NET :(

How can I destroy object (well, remove all references) if I am not
aware of them? Is it even possible? If not, how do you implement
complex code where one object is referenced from few different
locations???

Example follows:

I have Application class. I have Repository class that contains
applications. I have WorkingCopy class that contains also
applications.

I would like to point Repository and WorkingCopy to same application
object. But how should I proceed if I want to delete that object?

Martin
 
Hi guys,

I have project where few classes are interacting with each other...
Problem is that I probably still dont fully understand object life-
cycle in .NET :(

How can I destroy object (well, remove all references) if I am not
aware of them? Is it even possible? If not, how do you implement
complex code where one object is referenced from few different
locations???

Example follows:

I have Application class. I have Repository class that contains
applications. I have WorkingCopy class that contains also
applications.

I would like to point Repository and WorkingCopy to same application
object. But how should I proceed if I want to delete that object?

Remove it from both... Really that's the only real choice. Now, it
might be possible, depending on your scenario, to make one of them use a
WeakReference to the object - especially if you want to be able to
"resurect" the object.
 
Back
Top