Ufff, references and disposing problem

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
 
T

Tom Shelton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top