Esempio n. 1
0
            public IDisposable Run()
            {
                isDisposed   = false;
                e            = parent.sources.GetEnumerator();
                subscription = new SerialDisposable();

                var schedule = Scheduler.DefaultSchedulers.TailRecursion.Schedule(RecursiveRun);

                return(StableCompositeDisposable.Create(schedule, subscription, Disposable.Create(() =>
                {
                    lock (gate)
                    {
                        this.isDisposed = true;
                        this.e.Dispose();
                    }
                })));
            }
Esempio n. 2
0
        static AsyncSubject <TSource> RunAsync <TSource>(IConnectableObservable <TSource> source, CancellationToken cancellationToken)
        {
            var s = new AsyncSubject <TSource>();

            if (cancellationToken.IsCancellationRequested)
            {
                return(Cancel(s, cancellationToken));
            }

            var d = source.Subscribe(s);
            var c = source.Connect();

            if (cancellationToken.CanBeCanceled)
            {
                RegisterCancelation(s, StableCompositeDisposable.Create(d, c), cancellationToken);
            }

            return(s);
        }
Esempio n. 3
0
            public IDisposable Run()
            {
                IDisposable subscription;

                try
                {
                    subscription = parent.source.Subscribe(this);
                }
                catch
                {
                    // This behaviour is not same as .NET Official Rx
                    parent.finallyAction();
                    throw;
                }

                return(StableCompositeDisposable.Create(subscription, Disposable.Create(() =>
                {
                    parent.finallyAction();
                })));
            }
Esempio n. 4
0
            public IDisposable Run()
            {
                isDisposed = false;

                var sourceDisposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(sourceDisposable, Disposable.Create(() =>
                {
                    lock (scheduleDisposables)
                    {
                        isDisposed = true;

                        foreach (var item in scheduleDisposables)
                        {
                            item.Dispose();
                        }
                        scheduleDisposables.Clear();
                    }
                })));
            }
Esempio n. 5
0
            public IDisposable Run()
            {
                sourceSubscription            = new SingleAssignmentDisposable();
                sourceSubscription.Disposable = parent.source.Subscribe(this);


                IDisposable scheduling;
                var         periodicScheduler = parent.scheduler as ISchedulerPeriodic;

                if (periodicScheduler != null)
                {
                    scheduling = periodicScheduler.SchedulePeriodic(parent.interval, OnNextTick);
                }
                else
                {
                    scheduling = parent.scheduler.Schedule(parent.interval, OnNextRecursive);
                }

                return(StableCompositeDisposable.Create(sourceSubscription, scheduling));
            }
Esempio n. 6
0
            public IDisposable Run()
            {
                cancelable = new SerialDisposable();

                active      = false;
                running     = false;
                queue       = new Queue <Timestamped <T> >();
                onCompleted = false;
                completeAt  = default(DateTimeOffset);
                hasFailed   = false;
                exception   = default(Exception);
                ready       = true;
                delay       = Scheduler.Normalize(parent.dueTime);

                var _sourceSubscription = new SingleAssignmentDisposable();

                sourceSubscription             = _sourceSubscription; // assign to field
                _sourceSubscription.Disposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(sourceSubscription, cancelable));
            }
Esempio n. 7
0
            public IDisposable Run()
            {
                leftSubscription  = new SingleAssignmentDisposable();
                rightSubscription = new SingleAssignmentDisposable();
                var d = StableCompositeDisposable.Create(leftSubscription, rightSubscription);

                var left = new Amb();

                left.targetDisposable = d;
                left.targetObserver   = new AmbDecisionObserver(this, AmbState.Left, rightSubscription, left);

                var right = new Amb();

                right.targetDisposable = d;
                right.targetObserver   = new AmbDecisionObserver(this, AmbState.Right, leftSubscription, right);

                leftSubscription.Disposable  = parent.source.Subscribe(left);
                rightSubscription.Disposable = parent.second.Subscribe(right);

                return(d);
            }
Esempio n. 8
0
            public IDisposable Run()
            {
                var subscription = parent.sources.Subscribe(this);

                return(StableCompositeDisposable.Create(subscription, innerSubscription));
            }
Esempio n. 9
0
            public IDisposable Run()
            {
                var sourceDisposable = parent.source.Subscribe(this);

                return(StableCompositeDisposable.Create(sourceDisposable, isDisposed));
            }