المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Calling destructor in C# - observer pattern problem



C# Programming
02-11-2011, 01:52 PM
How to destroy object (observer) if it is referenced in another class and in destruction code of the observer it asks the subject to detatch it?
In C++ it is possible to call delete to invoke destructor but in C# assigning null to observer object will not release it as there is active reference in the subject.
Once the observer attached to its subject it is not possible to stop observation following strictly destructor patterns as in C++.
What is the best way to destroy observer object?
<div class="signature">