public void Dispose() { // Use atomic exchange to ensure that Unsubscribe() is only called once, // even if Dispose() is called simultaneously. IObserver <T> observer = Interlocked.Exchange(ref _observer, null); if (observer != null) { _subject.Unsubscribe(observer); _subject = null; } }
public Subscription(WeakSubject <T> subject, IObserver <T> observer) { _subject = subject; _observer = observer; }