예제 #1
0
            private void OnDestroy()
            {
                if (_updateSource != null)
                {
                    _updateSource.Dispose();
                    _updateSource = null;
                }

                if (_lateUpdateSource != null)
                {
                    _lateUpdateSource.Dispose();
                    _lateUpdateSource = null;
                }

                if (_fixedUpdateSource != null)
                {
                    _fixedUpdateSource.Dispose();
                    _fixedUpdateSource = null;
                }

                if (_eofUpdateSource != null)
                {
                    _eofUpdateSource.Dispose();
                    _eofUpdateSource = null;
                }
            }
예제 #2
0
        public void Dispose_CallsCompleted()
        {
            // Arrange
            var updateSource = new AsyncUpdateSource();
            var observer     = Substitute.For <IObserver <float> >();

            updateSource.Subscribe(observer);

            // Act
            updateSource.Dispose();

            // Assert
            observer.Received().OnCompleted();
        }
예제 #3
0
        public void Unsubscribe_CanBeCalledFromDispose()
        {
            // Arrange
            var updateSource = new AsyncUpdateSource();
            var observer     = Substitute.For <IObserver <float> >();
            var subscription = updateSource.Subscribe(observer);

            observer.When(x => x.OnCompleted()).Do(x => subscription.Dispose());

            // Act
            updateSource.Dispose();

            // Assert
            observer.Received(1).OnCompleted();
        }
예제 #4
0
            private void OnDestroy()
            {
                if (_updateSource != null)
                {
                    _updateSource.Dispose();
                    _updateSource = null;
                }

                if (_lateUpdateSource != null)
                {
                    _lateUpdateSource.Dispose();
                    _lateUpdateSource = null;
                }

                if (_fixedUpdateSource != null)
                {
                    _fixedUpdateSource.Dispose();
                    _fixedUpdateSource = null;
                }

                if (_eofUpdateSource != null)
                {
                    _eofUpdateSource.Dispose();
                    _eofUpdateSource = null;
                }

                if (_context != null && _context == SynchronizationContext.Current)
                {
                    SynchronizationContext.SetSynchronizationContext(null);
                }

#if NET_2_0 || NET_2_0_SUBSET
                lock (_actionQueue)
                {
                    _actionQueue.Clear();
                }
#endif

                _mainThreadContext = null;
                _context           = null;
            }