// Token: 0x0600413C RID: 16700 RVA: 0x000F2518 File Offset: 0x000F0718
        private void ProcessAsyncIfNecessary(bool fairly = false)
        {
            if (this.m_processingCount >= 0)
            {
                bool flag = !this.m_exclusiveTaskScheduler.m_tasks.IsEmpty;
                Task task = null;
                if (this.m_processingCount == 0 && flag)
                {
                    this.m_processingCount = -1;
                    try
                    {
                        task = new Task(delegate(object thisPair)
                        {
                            ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessExclusiveTasks();
                        }, this, default(CancellationToken), ConcurrentExclusiveSchedulerPair.GetCreationOptionsForTask(fairly));
                        task.Start(this.m_underlyingTaskScheduler);
                        goto IL_149;
                    }
                    catch
                    {
                        this.m_processingCount = 0;
                        this.FaultWithTask(task);
                        goto IL_149;
                    }
                }
                int count = this.m_concurrentTaskScheduler.m_tasks.Count;
                if (count > 0 && !flag && this.m_processingCount < this.m_maxConcurrencyLevel)
                {
                    int num = 0;
                    while (num < count && this.m_processingCount < this.m_maxConcurrencyLevel)
                    {
                        this.m_processingCount++;
                        try
                        {
                            task = new Task(delegate(object thisPair)
                            {
                                ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessConcurrentTasks();
                            }, this, default(CancellationToken), ConcurrentExclusiveSchedulerPair.GetCreationOptionsForTask(fairly));
                            task.Start(this.m_underlyingTaskScheduler);
                        }
                        catch
                        {
                            this.m_processingCount--;
                            this.FaultWithTask(task);
                        }
                        num++;
                    }
                }
IL_149:
                this.CleanupStateIfCompletingAndQuiesced();
            }
        }
コード例 #2
0
        private void ProcessAsyncIfNecessary(bool fairly = false)
        {
            if (this.m_processingCount < 0)
            {
                return;
            }
            bool flag        = !this.m_exclusiveTaskScheduler.m_tasks.IsEmpty;
            Task faultedTask = (Task)null;

            if (this.m_processingCount == 0 & flag)
            {
                this.m_processingCount = -1;
                try
                {
                    CancellationToken cancellationToken = new CancellationToken();
                    int num = (int)ConcurrentExclusiveSchedulerPair.GetCreationOptionsForTask(fairly);
                    faultedTask = new Task((Action <object>)(thisPair => ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessExclusiveTasks()), (object)this, cancellationToken, (TaskCreationOptions)num);
                    faultedTask.Start(this.m_underlyingTaskScheduler);
                }
                catch
                {
                    this.m_processingCount = 0;
                    this.FaultWithTask(faultedTask);
                }
            }
            else
            {
                int count = this.m_concurrentTaskScheduler.m_tasks.Count;
                if (count > 0 && !flag && this.m_processingCount < this.m_maxConcurrencyLevel)
                {
                    for (int index = 0; index < count && this.m_processingCount < this.m_maxConcurrencyLevel; ++index)
                    {
                        this.m_processingCount = this.m_processingCount + 1;
                        try
                        {
                            CancellationToken cancellationToken = new CancellationToken();
                            int num = (int)ConcurrentExclusiveSchedulerPair.GetCreationOptionsForTask(fairly);
                            faultedTask = new Task((Action <object>)(thisPair => ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessConcurrentTasks()), (object)this, cancellationToken, (TaskCreationOptions)num);
                            faultedTask.Start(this.m_underlyingTaskScheduler);
                        }
                        catch
                        {
                            this.m_processingCount = this.m_processingCount - 1;
                            this.FaultWithTask(faultedTask);
                        }
                    }
                }
            }
            this.CleanupStateIfCompletingAndQuiesced();
        }