⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taskexecutionworker.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace NCindy.Threading
{
    using System;
    using System.Threading;

    internal class TaskExecutionWorker
    {
        private bool isRunning;
        private readonly NCindy.Threading.ThreadPool parentPool;
        public Thread thread;

        public TaskExecutionWorker(NCindy.Threading.ThreadPool parentPool)
        {
            this.parentPool = parentPool;
        }

        private void CheckShutdownComplete()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        private void CheckStartupComplete()
        {
        }

        internal void ExecutionLoop()
        {
            int num;
            this.CheckStartupComplete();
        Label_0006:
            num = 0;
            ITask task = null;
            try
            {
                while (true)
                {
                    if (num == 0)
                    {
                        if (this.thread == null)
                        {
                            break;
                        }
                        this.WaitForTask();
                    }
                    num = 0;
                    int num2 = this.parentPool.taskQueueList.get_Count();
                    for (int i = 0; i < num2; i++)
                    {
                        if (num2 != this.parentPool.taskQueueList.get_Count())
                        {
                            break;
                        }
                        try
                        {
                            this.parentPool.taskQueueList.get_Item(i);
                        }
                        catch
                        {
                            break;
                        }
                    }
                }
                this.CheckShutdownComplete();
            }
            catch (Exception exception)
            {
                this.HandleException(task, exception);
                goto Label_0006;
            }
        }

        private void HandleException(ITask task, Exception exception)
        {
        }

        internal void Signal()
        {
            if (!this.isRunning)
            {
                lock (this)
                {
                    if (!this.isRunning)
                    {
                        Monitor.Pulse(this);
                    }
                }
            }
        }

        private void WaitForTask()
        {
            if (this.parentPool.pendingTaskCount == 0)
            {
                this.isRunning = false;
                lock (this)
                {
                    if (this.parentPool.pendingTaskCount == 0)
                    {
                        Monitor.Wait(this);
                    }
                }
                this.isRunning = true;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -