Esempio n. 1
0
            public void Dispose()
            {
                lock (gate)
                {
                    if (parent != null)
                    {
                        lock (parent.observerLock)
                        {
                            var listObserver = parent.outObserver as ListObserver <T>;
                            if (listObserver != null)
                            {
                                parent.outObserver = listObserver.Remove(unsubscribeTarget);
                            }
                            else
                            {
                                parent.outObserver = new EmptyObserver <T>();
                            }

                            unsubscribeTarget = null;
                            parent            = null;
                        }
                    }
                }
            }
        public static Func <IObservable <Unit> > ToAsync(Action action, IScheduler scheduler)
        {
            return(() =>
            {
                var subject = new AsyncSubject <Unit>();

                scheduler.Schedule(() =>
                {
                    try
                    {
                        action();
                    }
                    catch (Exception exception)
                    {
                        subject.OnError(exception);
                        return;
                    }
                    subject.OnNext(Unit.Default);
                    subject.OnCompleted();
                });

                return subject.AsObservable();
            });
        }
Esempio n. 3
0
 public Subscription(AsyncSubject <T> parent, IObserver <T> unsubscribeTarget)
 {
     this.parent            = parent;
     this.unsubscribeTarget = unsubscribeTarget;
 }