private void OnUnload(object sender, RoutedEventArgs e) { _visualsObserver?.Dispose(); ViewportRenderer?.Dispose(); ViewportRenderer = null; Camera.PropertyChanged -= OnCameraChanged; Camera.Space.GetRoot().Changed -= OnCameraChanged; }
public void DisposeTest() { ObservableCollection <string> coll = new ObservableCollection <string>(new[] { "This", "is", "a", "test" }); ReceiverTest test = new ReceiverTest(); var observer = new CollectionObserver(coll); observer.CollectionChanged += test.OnObserver; observer.Dispose(); coll.Clear(); Assert.AreEqual(0, test.List.Count); }
public void GCDisposeTest() { ObservableCollection <string> coll = new ObservableCollection <string>(new[] { "This", "is", "a", "test" }); WeakReference weakReference = new WeakReference(coll); ReceiverTest test = new ReceiverTest(); var observer = new CollectionObserver(coll); observer.CollectionChanged += test.OnObserver; observer.Dispose(); coll = null; Assert.AreEqual(0, test.List.Count); test = null; GC.Collect(2, GCCollectionMode.Forced); Assert.IsFalse(weakReference.IsAlive); }