Example #1
0
        private static void NestIterator(ITask currentTask)
        {
            ITask   t = currentTask;
            Handler arbiterCleanup = t.ArbiterCleanupHandler;

            t.ArbiterCleanupHandler = delegate
            {
                t.ArbiterCleanupHandler = arbiterCleanup;
                TaskExecutionWorker.ExecuteTask(ref t, t.TaskQueue, true);
            };
            currentTask.TaskQueue.Enqueue(t);
        }
Example #2
0
        public static void ExecuteInCurrentThreadContext(object t)
        {
            ITask task = (ITask)t;

            try
            {
                TaskExecutionWorker.ExecuteTask(ref task, task.TaskQueue, false);
                Dispatcher.SetCurrentThreadCausalities(null);
            }
            catch (Exception ex)
            {
                if (TaskExecutionWorker.IsCriticalException(ex))
                {
                    throw;
                }
                TaskExecutionWorker.HandleException(task, ex);
            }
        }
Example #3
0
        internal void ExecutionLoop()
        {
            CheckStartupComplete();
            while (true)
            {
IL_06:
                int num = 0;
                int   num2        = 0;
                ITask currentTask = null;
                try
                {
                    bool flag = false;
                    while (true)
                    {
                        if (num == 0)
                        {
                            if (_thread == null)
                            {
                                break;
                            }
                            WaitForTask(flag);
                        }
                        num2++;
                        num = 0;
                        int cachedDispatcherQueueCount = _dispatcher._cachedDispatcherQueueCount;
                        for (int i = 0; i < cachedDispatcherQueueCount; i++)
                        {
                            if (cachedDispatcherQueueCount != _dispatcher._cachedDispatcherQueueCount)
                            {
                                goto Block_5;
                            }
                            DispatcherQueue dispatcherQueue;
                            try
                            {
                                dispatcherQueue = _dispatcher._dispatcherQueues[(i + num2) % cachedDispatcherQueueCount];
                            }
                            catch
                            {
                                goto IL_06;
                            }
                            if (_isFastTimerLogicEnabled)
                            {
                                flag |= dispatcherQueue.CheckTimerExpirations();
                            }
                            if (dispatcherQueue.TryDequeue(out currentTask))
                            {
                                num += dispatcherQueue.Count;
                                TaskExecutionWorker.ExecuteTask(ref currentTask, dispatcherQueue, false);
                            }
                        }
                    }
                    Dispatcher.ClearCausalities();
                    CheckShutdownComplete();
                    Dispatcher.ClearCausalities();
                    break;
Block_5:
                    continue;
                }
                catch (Exception ex)
                {
                    if (TaskExecutionWorker.IsCriticalException(ex))
                    {
                        throw;
                    }
                    TaskExecutionWorker.HandleException(currentTask, ex);
                    continue;
                }
            }
        }