Ejemplo n.º 1
0
        public void Dispose()
        {
            if (isDisposed)
            {
                return;
            }

            logger.Info($"{streamType}:");

            DisableInput();
            DisableTransfer();

            playbackErrorSubject.Dispose();

            _bufferingSubject.OnCompleted();
            _bufferingSubject.Dispose();
            _packetProcessed.OnCompleted();
            _packetProcessed.Dispose();

            transferCts?.Dispose();
            linkedCts?.Dispose();

            currentPacket?.Dispose();

            isDisposed = true;
        }
Ejemplo n.º 2
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }
            _isDisposed = true;

            if (isDisposing)
            {
                Disconnect().Wait(5000);

                _outMessages.Dispose();
                _outMessages = null;

                _inMessages.Dispose();
                _inMessages = null;

                _inMessagesHistory.Dispose();
                _inMessagesHistory = null;

                _outMessagesHistory.Dispose();
                _outMessagesHistory = null;
            }
        }
Ejemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _result.Dispose();
     }
 }
Ejemplo n.º 4
0
        private void Start()
        {
            // 過去3メッセージまでキャッシュするReplaySubject
            var subject = new ReplaySubject <int>(bufferSize: 3);

            //メッセージを発行
            for (int i = 0; i < 10; i++)
            {
                subject.OnNext(i);
            }

            // OnCompletedメッセージもキャッシュされる
            subject.OnCompleted();

            // OnErrorメッセージもキャッシュできる
            // subject.OnError(new Exception("Error!"));

            // 購読
            subject.Subscribe(
                x => Debug.Log("OnNext:" + x),
                ex => Debug.LogError("OnError:" + ex),
                () => Debug.Log("OnCompleted"));

            subject.Dispose();
        }
Ejemplo n.º 5
0
 public void Dispose()
 {
     if (m_subject != null)
     {
         m_subject.Dispose();
     }
 }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         _messageSubject?.Dispose();
     }
 }
Ejemplo n.º 7
0
        public override void Dispose()
        {
            base.Dispose();

            actualItemSubject?.Dispose();
            View?.Dispose();
        }
Ejemplo n.º 8
0
        public static IObservable <T> Pausable <T>(
            this IObservable <T> source,
            IObservable <bool> pauser)
        {
            return(Observable.Create <T>(o => {
                var paused = new SerialDisposable();
                var subscription = Observable.Publish(source, ps => {
                    var values = new ReplaySubject <T>();
                    Func <bool, IObservable <T> > switcher = b => {
                        if (b)
                        {
                            values.Dispose();
                            values = new ReplaySubject <T>();
                            paused.Disposable = ps.Subscribe(values);
                            return Observable.Empty <T>();
                        }
                        else
                        {
                            return values.Concat(ps);
                        }
                    };

                    return pauser.StartWith(false).DistinctUntilChanged()
                    .Select(p => switcher(p))
                    .Switch();
                }).Subscribe(o);
                return new CompositeDisposable(subscription, paused);
            }));
        }
 public void Dispose()
 {
     if (_workspaceFoldersSubject.IsDisposed)
     {
         return;
     }
     _workspaceFoldersSubject.Dispose();
 }
Ejemplo n.º 10
0
        public static void Broadcast <T>(IObservable <T> recievers, Action <T> lambda)
        {
            var broadcast = new ReplaySubject <T>();

            broadcast.ForEachAsync(lambda);
            recievers.Subscribe(cl => broadcast.OnNext(cl), () => broadcast.OnCompleted());
            broadcast.Dispose();
        }
        public void HasObservers_Dispose3()
        {
            var s = new ReplaySubject <int>();

            Assert.IsFalse(s.HasObservers);

            s.Dispose();
            Assert.IsFalse(s.HasObservers);
        }
Ejemplo n.º 12
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                _evictionEvent?.Dispose();
            }
        }
Ejemplo n.º 13
0
        private void DisposeAllSubjects()
        {
            playbackErrorSubject.Dispose();
            stateChangedSubject.OnCompleted();
            stateChangedSubject.Dispose();
            bufferingProgressSubject.OnCompleted();
            bufferingProgressSubject.Dispose();

            logger.Info("End");
        }
Ejemplo n.º 14
0
 public void Dispose()
 {
     try
     {
         _subject.Dispose();
     }
     catch (Exception)
     {
     }
 }
 public void Initialized()
 {
     if (_delayComplete || _delayedQueue.IsDisposed || !_delayedQueue.HasObservers)
     {
         return;
     }
     _delayedQueue.OnCompleted();
     _delayComplete = true;
     _delayedQueue.Dispose();
 }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!disposing)
            {
                return;
            }

            _reputationEvent?.Dispose();
        }
        public void Dispose()
        {
            itemAddedSubject?.Dispose();
            itemRemovedSubject?.Dispose();
            itemUpdatedSubject?.Dispose();

            foreach (var disposable in itemsDisposables)
            {
                disposable.Dispose();
            }
        }
Ejemplo n.º 18
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _foundDeltaHeightSubject.Dispose();
         }
     }
     _disposed = true;
 }
Ejemplo n.º 19
0
            /// <inheritdoc />
            public void Dispose()
            {
                this.Log().Info("Disposing MQTT subscription");

                _restore.Dispose();
                _subscription.Dispose();

                _status.OnNext(MqttConnectionStatus.Disabled);
                _status.OnCompleted();
                _status.Dispose();
            }
Ejemplo n.º 20
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _payloadSequence.OnCompleted();
            _payloadSequence.Dispose();
            _disposed = true;
        }
Ejemplo n.º 21
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _subject.Dispose();
                }

                disposedValue = true;
            }
        }
Ejemplo n.º 22
0
 protected override void Dispose(bool disposing)
 {
     if (_disposed == false)
     {
         if (disposing)
         {
             Clear();
             _recordersSubscription.Dispose();
             _recordings.Dispose();
         }
         _disposed = true;
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 23
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                payloadSequence.OnCompleted();
                payloadSequence.Dispose();
                disposed = true;
            }
        }
Ejemplo n.º 24
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _eventReplySubject.Dispose();
            }

            _disposed = true;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Disposes of resources inside the class.
        /// </summary>
        /// <param name="isDisposing">If we are disposing managed resources.</param>
        protected virtual void Dispose(bool isDisposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (isDisposing)
            {
                _activated?.Dispose();
            }

            _isDisposed = true;
        }
Ejemplo n.º 26
0
 protected override void Dispose(bool disposing)
 {
     if (_disposed == false)
     {
         if (disposing)
         {
             Disconnect();
             _recording.Dispose();
             _gazeSources.Dispose();
         }
         _disposed = true;
     }
     base.Dispose(disposing);
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Disposes of the managed resources as well as the reporting channels
        /// </summary>
        public virtual void Dispose()
        {
            if (!IsDisposed)
            {
                IsDisposed = true;
                ManagedResources.DisposeAll();

                ReportInformation.OnCompleted();
                ReportExceptions.OnCompleted();

                ReportInformation.Dispose();
                ReportExceptions.Dispose();
            }
        }
Ejemplo n.º 28
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _receiver.Dispose();
             _subscription.Close();
             _mqChannel.Close();
             _mqConnection.Close();
             _messageStream.OnCompleted();
             _messageStream.Dispose();
         }
         _disposed = true;
     }
 }
        public void HasObservers_Dispose2()
        {
            var s = new ReplaySubject <int>();

            Assert.IsFalse(s.HasObservers);

            var d = s.Subscribe(_ => { });

            Assert.IsTrue(s.HasObservers);

            d.Dispose();
            Assert.IsFalse(s.HasObservers);

            s.Dispose();
            Assert.IsFalse(s.HasObservers);
        }
Ejemplo n.º 30
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed == false)
            {
                if (disposing)
                {
                    TryCancel();

                    _events.Dispose();

                    //var recorders = _recorders.ToList();
                    //_recorders.Clear();
                    //recorders.OfType<IDisposable>().ForEach(r => r.Dispose());
                }
                _disposed = true;
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Fires a stream of RoleIds when you should reload.
        /// This happens whenever an Observer is active and the RoleId has changed.
        /// </summary>
        /// <returns>
        /// An Observable that fires the RoleId whenever data should be updated.
        /// </returns>
        protected IObservable<Guid> SetupExecuteObservable()
        {
            var loadQuery = Manager.Context.RoleIdObservable;

            var combinedObservationStateChanges = this.ObservationState;

            //loadQuery.Subscribe(s => Debug.WriteLine(String.Format("{0} RoleId {1}", queryKey, s)));
            //combinedObservationStateChanges.Subscribe(s => Debug.WriteLine(String.Format("{0} ObservationState {1}", queryKey, s)));

            //See http://stackoverflow.com/questions/7716114/rx-window-join-groupjoin for explanation
            var loadQueryUpdatesWhileInactive = new ReplaySubject<Guid>(1);
            var disposer = new SerialDisposable();

            //the getSwitch will 
            //a) publish loadQueryUpdates if the observation state is active
            //b) track loadQueryUpdates when ObservationState = suspended, then publish the loadQueryUpdate once active
            Func<ObservationState, IObservable<ObservationState>, IObservable<Guid>, IObservable<Guid>> getSwitch =
                (observationStateUpdate, observationStateUpdates, loadQueryUpdates) =>
                {
                    //a) because the observationState is active publish the loadQueryUpdatesWhileInactive & the loadQueryUpdates
                    if (observationStateUpdate == Common.Models.ObservationState.Active)
                    {
                        //Merge the loadQueryUpdatesWhileInactive with the loadQueryUpdates
                        return loadQueryUpdatesWhileInactive.Merge(loadQueryUpdates);
                    }

                    //b) because the ObservationState is suspended:
                    //   setup loadQueryUpdatesWhileInactive to keep track of the loadQueryUpdates while inactive

                    //dispose the last loadQueryUpdatesWhileInactive subscription
                    loadQueryUpdatesWhileInactive.Dispose();

                    //setup loadQueryUpdatesWhileInactive to track 1 (the last) loadQuery update
                    loadQueryUpdatesWhileInactive = new ReplaySubject<Guid>(1);

                    //dispose the temporary subscription to loadQueryUpdates
                    disposer.Disposable =
                        //track loadQueryUpdates until the next observationStateUpdates
                        loadQueryUpdates.TakeUntil(observationStateUpdates)
                        .Subscribe(loadQueryUpdatesWhileInactive); //setup loadQueryUpdatesWhileInactive

                    //return an Empty Guid Observable so that executeQuery does not publish anything 
                    return Observable.Empty<Guid>();
                };

            //Create an Observable that fires the RoleId whenever data should be updated
            //The logic for when it should fire is defined in the getSwitch
            var executeQuery =
                combinedObservationStateChanges.DistinctUntilChanged() //whenever the combineObservationState changes
                    .Publish(observationStateUpdates => loadQuery  //publish the observationStateUpdates
                        .Publish(loadQueryUpdates =>  //publish the loadQueryUpdates
                            observationStateUpdates.Select( //select according to the getSwitch logic
                            observationStateUpdate =>
                                getSwitch(observationStateUpdate, observationStateUpdates, loadQueryUpdates))))
                    .Switch()
                    .Throttle(new TimeSpan(0, 0, 0, 0, 200));//Throttle for .2 second so it does not execute too often

            executeQuery.Subscribe(s => Debug.WriteLine(String.Format("Load data for {0} with RoleId {1}", GetType(), s)));

            return executeQuery;
        }
Ejemplo n.º 32
0
        public void HasObservers_Dispose2()
        {
            var s = new ReplaySubject<int>();
            Assert.IsFalse(s.HasObservers);

            var d = s.Subscribe(_ => { });
            Assert.IsTrue(s.HasObservers);

            d.Dispose();
            Assert.IsFalse(s.HasObservers);

            s.Dispose();
            Assert.IsFalse(s.HasObservers);
        }
Ejemplo n.º 33
0
        private static void HasObservers_Dispose3(ReplaySubject<int> s)
        {
            Assert.False(s.HasObservers);
            Assert.False(s.IsDisposed);

            s.Dispose();
            Assert.False(s.HasObservers);
            Assert.True(s.IsDisposed);
        }
Ejemplo n.º 34
0
        private static void HasObservers_Dispose2(ReplaySubject<int> s)
        {
            Assert.False(s.HasObservers);
            Assert.False(s.IsDisposed);

            var d = s.Subscribe(_ => { });
            Assert.True(s.HasObservers);
            Assert.False(s.IsDisposed);

            d.Dispose();
            Assert.False(s.HasObservers);
            Assert.False(s.IsDisposed);

            s.Dispose();
            Assert.False(s.HasObservers);
            Assert.True(s.IsDisposed);
        }
Ejemplo n.º 35
0
        public void HasObservers_Dispose3()
        {
            var s = new ReplaySubject<int>();
            Assert.IsFalse(s.HasObservers);

            s.Dispose();
            Assert.IsFalse(s.HasObservers);
        }