void IWork.DoWork(ParallelTasks.WorkData workData = null) { m_timer.Start(); MyPrecalcJob work; while (Queue.TryDequeueFront(out work)) { if (work.IsCanceled) { m_finishedList.Add(work); continue; } try { ProfilerShort.Begin("MyPrecalcWork"); work.DoWork(); } finally { ProfilerShort.End(); } m_finishedList.Add(work); if (m_timer.ElapsedMilliseconds >= MaxPrecalcTime) { break; } if (MyFakes.ENABLE_YIELDING_IN_PRECALC_TASK) { Thread.Yield(); } } m_timer.Stop(); m_timer.Reset(); }