/// <summary> /// Advances to the next task in the queue. /// </summary> /// <param name="toStart">The job that will be started.</param> private void AdvanceNext(IWork toStart) { int n = threads.Length; nextWorkIndex = -1; activeThreads = n; currentJob = toStart; // Not sure if this matters, borrowed from Klei code Thread.MemoryBarrier(); toStart.TriggerStart(); semaphore.Release(n); }