예제 #1
0
 public static void Subscribe <T>(
     this Schedulable <T> schedulable,
     IScheduler scheduler,
     Action <T> onCompleted,
     Action <Exception> onError)
 {
     schedulable.ContinueWith(scheduler, onCompleted);
     TaskChain.Schedule(schedulable.GetRoot(), onError);
 }
            public void Enqueue(TaskChain item)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(_ =>
                {
                    if (item == null)
                    {
                        return;
                    }

                    while (true)
                    {
                        var status = item.Next();
                        if (status != ExecutionStatus.Continue)
                        {
                            break;
                        }
                    }
                });
            }
예제 #3
0
        public static TaskChain Schedule(ISchedulable schedulable, Action <Exception> onError)
        {
            var item = new TaskChain
            {
                Enumerator = schedulable.Traverse().GetEnumerator(),
                OnError    = onError
            };

            if (item.Enumerator.MoveNext())
            {
                if (item.Enumerator.Current.Schedulder == null)
                {
                    // default
                    Scheduler.MainThread.Enqueue(item);
                }
                else
                {
                    item.Enumerator.Current.Schedulder.Enqueue(item);
                }
            }

            return(item);
        }
예제 #4
0
            public void Enqueue(TaskChain item)
            {
                var q = GetQueue();

                if (q == null)
                {
                    q = new Queue <TaskChain>(5);
                    q.Enqueue(item);
                    SetQueue(q);

                    try
                    {
                        Trampoline.Run(q);
                    }
                    finally
                    {
                        SetQueue(null);
                    }
                }
                else
                {
                    q.Enqueue(item);
                }
            }
예제 #5
0
 public void Enqueue(TaskChain item)
 {
     m_queue.Enqueue(item);
 }