Ejemplo n.º 1
0
            public void Run(ToObservable <TSource> parent)
            {
                var e = default(IEnumerator <TSource>);

                try
                {
                    e = parent._source.GetEnumerator();
                }
                catch (Exception exception)
                {
                    ForwardOnError(exception);

                    return;
                }

                var longRunning = parent._scheduler.AsLongRunning();

                if (longRunning != null)
                {
                    //
                    // Long-running schedulers have the contract they should *never* prevent
                    // the work from starting, such that the scheduled work has the chance
                    // to observe the cancellation and perform proper clean-up. In this case,
                    // we're sure Loop will be entered, allowing us to dispose the enumerator.
                    //
                    SetUpstream(longRunning.ScheduleLongRunning((@this: this, e), (tuple, cancelable) => [email protected](tuple.e, cancelable)));
                }
                else
                {
                    //
                    // We never allow the scheduled work to be cancelled. Instead, the flag
                    // is used to have LoopRec bail out and perform proper clean-up of the
                    // enumerator.
                    //
                    var flag = new BooleanDisposable();
                    parent._scheduler.Schedule(new State(this, flag, e), (state, action) => state.sink.LoopRec(state, action));
                    SetUpstream(flag);
                }
            }
Ejemplo n.º 2
0
            public IDisposable Run(ToObservable <TSource> parent)
            {
                var e = default(IEnumerator <TSource>);

                try
                {
                    e = parent._source.GetEnumerator();
                }
                catch (Exception exception)
                {
                    base._observer.OnError(exception);
                    base.Dispose();
                    return(Disposable.Empty);
                }

                var longRunning = parent._scheduler.AsLongRunning();

                if (longRunning != null)
                {
                    //
                    // Long-running schedulers have the contract they should *never* prevent
                    // the work from starting, such that the scheduled work has the chance
                    // to observe the cancellation and perform proper clean-up. In this case,
                    // we're sure Loop will be entered, allowing us to dispose the enumerator.
                    //
                    return(longRunning.ScheduleLongRunning(e, Loop));
                }
                else
                {
                    //
                    // We never allow the scheduled work to be cancelled. Instead, the flag
                    // is used to have LoopRec bail out and perform proper clean-up of the
                    // enumerator.
                    //
                    var flag = new BooleanDisposable();
                    parent._scheduler.Schedule(new State(flag, e), LoopRec);
                    return(flag);
                }
            }
Ejemplo n.º 3
0
 public _(ToObservable <TSource> parent, IObserver <TSource> observer, IDisposable cancel)
     : base(observer, cancel)
 {
     _parent = parent;
 }