Ejemplo n.º 1
0
            private void ProcessNext()
            {
                lock (actions)
                {
                    if (actions.Count == 0 || isDisposed)
                    {
                        return;
                    }

                    SchedulableAction action = actions.First.Value;

                    if (action.IsScheduled)
                    {
                        return;
                    }

                    action.schedule = parent.scheduler.Schedule(() =>
                    {
                        try
                        {
                            switch (action.data.Kind)
                            {
                            case NotificationKind.OnNext:
                                observer.OnNext(action.data.Value);
                                break;

                            case NotificationKind.OnError:
                                observer.OnError(action.data.Exception);
                                break;

                            case NotificationKind.OnCompleted:
                                observer.OnCompleted();
                                break;
                            }
                        }
                        finally
                        {
                            lock (actions)
                            {
                                action.Dispose();
                            }

                            if (action.data.Kind == NotificationKind.OnNext)
                            {
                                ProcessNext();
                            }
                            else
                            {
                                Dispose();
                            }
                        }
                    });
                }
            }
Ejemplo n.º 2
0
            private void QueueAction(Notification <T> data)
            {
                var action = new SchedulableAction {
                    data = data
                };

                lock (actions) {
                    if (isDisposed)
                    {
                        return;
                    }

                    action.node = actions.AddLast(action);
                    ProcessNext();
                }
            }