Jitter.ThreadManager.Execute C# (CSharp) Method

Execute() public method

Executes all tasks previously added to the ThreadManager. The method finishes when all tasks are complete.
public Execute ( ) : void
return void
        public void Execute()
        {
            currentTaskIndex = 0;
            waitingThreadCount = 0;

            currentWaitHandle.Set();
            PumpTasks();

            while (waitingThreadCount < threads.Length - 1) Thread.Sleep(0);

            currentWaitHandle.Reset();
            currentWaitHandle = (currentWaitHandle == waitHandleA) ? waitHandleB : waitHandleA;

            tasks.Clear();
            parameters.Clear();
        }

Usage Example

Ejemplo n.º 1
0
        private void HandleArbiter(int iterations, bool multiThreaded)
        {
            if (multiThreaded)
            {
                for (int i = 0; i < islands.Count; i++)
                {
                    if (islands[i].IsActive())
                    {
                        threadManager.AddTask(arbiterCallback, islands[i]);
                    }
                }

                threadManager.Execute();
            }
            else
            {
                for (int i = 0; i < islands.Count; i++)
                {
                    if (islands[i].IsActive())
                    {
                        arbiterCallback(islands[i]);
                    }
                }
            }
        }