コード例 #1
0
        private void OnUnload(object sender, RoutedEventArgs e)
        {
            _visualsObserver?.Dispose();
            ViewportRenderer?.Dispose();
            ViewportRenderer = null;

            Camera.PropertyChanged -= OnCameraChanged;
            Camera.Space.GetRoot().Changed -= OnCameraChanged;
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }