Esempio n. 1
0
        public IObservable <Unit> ShutdownQueue()
        {
            lock (queuedOps)
            {
                if (shutdownObs != null)
                {
                    return(shutdownObs);
                }

                queuedOps.OnCompleted();

                shutdownObs = new AsyncSubject <Unit>();
                var sub = resultObs.Materialize()
                          .Where(x => x.Kind != NotificationKind.OnNext)
                          .SelectMany(x =>
                                      (x.Kind == NotificationKind.OnError) ?
                                      Observable.Throw <Unit>(x.Exception) :
                                      Observable.Return(Unit.Default))
                          .Multicast(shutdownObs);

                sub.Connect();

                return(shutdownObs);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Shuts down the queue and notifies when all outstanding items have
        /// been processed.
        /// </summary>
        /// <returns>An Observable that will signal when all items are complete.
        /// </returns>
        public IObservable <Unit> ShutdownQueue()
        {
            lock (_queuedOps)
            {
                if (_shutdownObs != null)
                {
                    return(_shutdownObs);
                }

                _shutdownObs = new AsyncSubject <Unit>();

                // Disregard paused queue
                _scheduledGate.MaximumCount = _maximumConcurrent;

                _queuedOps.OnCompleted();

                _resultObs.Materialize()
                .Where(x => x.Kind != NotificationKind.OnNext)
                .SelectMany(x =>
                            x.Kind == NotificationKind.OnError ?
                            Observable.Throw <Unit>(x.Exception !) :
                            Observable.Return(Unit.Default))
                .Multicast(_shutdownObs)
                .Connect();

                return(_shutdownObs);
            }
        }