Esempio n. 1
0
        /// <summary>
        /// IThreadWorkerObject implementation: This method computes all the work.
        /// </summary>
        public void ExecuteThreadedWork()
        {
            if (workLoad == null || workLoad.Length == 0)
            {
                return;
            }

            //Debug.Log("Execute ID: " + ID + ", startIndex: " + startIndex  + ", endIndex: " + endIndex);
            if (workloadExecutor != null)
            {
                for (int i = startIndex; i < endIndex && !_isAborted; i++)
                {
                    UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                    workloadExecutor(workLoad[i]);
                }
            }
            else if (workloadExecutorIndexed != null)
            {
                for (int i = startIndex; i < endIndex && !_isAborted; i++)
                {
                    UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                    workloadExecutorIndexed(workLoad[i], i);
                }
            }
            else if (workloadExecutorArg != null)
            {
                for (int i = startIndex; i < endIndex && !_isAborted; i++)
                {
                    UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                    workloadExecutorArg(workLoad[i], extraArgument);
                }
            }
            else if (workloadExecutorArgIndexed != null)
            {
                for (int i = startIndex; i < endIndex && !_isAborted; i++)
                {
                    UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                    workloadExecutorArgIndexed(workLoad[i], i, extraArgument);
                }
            }
        }
        public void ExecuteThreadedWork()
        {
            bool flag = this.workLoad == null || this.workLoad.Length == 0;

            if (!flag)
            {
                bool flag2 = this.workloadExecutor != null;
                if (flag2)
                {
                    int num = this.startIndex;
                    while (num < this.endIndex && !this._isAborted)
                    {
                        UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                        this.workloadExecutor(this.workLoad[num]);
                        int num2 = num;
                        num = num2 + 1;
                    }
                }
                else
                {
                    bool flag3 = this.workloadExecutorIndexed != null;
                    if (flag3)
                    {
                        int num3 = this.startIndex;
                        while (num3 < this.endIndex && !this._isAborted)
                        {
                            UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                            this.workloadExecutorIndexed(this.workLoad[num3], num3);
                            int num2 = num3;
                            num3 = num2 + 1;
                        }
                    }
                    else
                    {
                        bool flag4 = this.workloadExecutorArg != null;
                        if (flag4)
                        {
                            int num4 = this.startIndex;
                            while (num4 < this.endIndex && !this._isAborted)
                            {
                                UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                                this.workloadExecutorArg(this.workLoad[num4], this.extraArgument);
                                int num2 = num4;
                                num4 = num2 + 1;
                            }
                        }
                        else
                        {
                            bool flag5 = this.workloadExecutorArgIndexed != null;
                            if (flag5)
                            {
                                int num5 = this.startIndex;
                                while (num5 < this.endIndex && !this._isAborted)
                                {
                                    UnityActivityWatchdog.SleepOrAbortIfUnityInactive();
                                    this.workloadExecutorArgIndexed(this.workLoad[num5], num5, this.extraArgument);
                                    int num2 = num5;
                                    num5 = num2 + 1;
                                }
                            }
                        }
                    }
                }
            }
        }