public static void Slice() { lock (m_Queue) { m_QueueCountAtSlice = m_Queue.Count; int index = 0; DateTime start = DateTime.MinValue; DateTime breakTime = DateTime.Now + m_BreakTime; while (index < m_BreakCount && DateTime.Now < breakTime && m_Queue.Count != 0) { Timer t = (Timer)m_Queue.Dequeue(); TimerProfile prof = t.GetProfile(); if (prof != null) { start = DateTime.Now; } // Adam: See comments at top of file regarding timer.Flush() if (t.Eat == true) { t.Eat = false; } else { try { t.OnTick(); } catch (Exception e) { // Log an exception EventSink.InvokeLogException(new LogExceptionEventArgs(e)); } } t.m_Queued = false; ++index; if (prof != null) { prof.RegTicked(DateTime.Now - start); } } //while !empty if (index >= m_BreakCount) { Console.WriteLine("Timer.Slice: index >= m_BreakCount"); } if (DateTime.Now >= breakTime) { Console.WriteLine("Timer.Slice: DateTime.Now >= breakTime"); } } }
public static void Slice() { lock ( m_Queue ) { m_QueueCountAtSlice = m_Queue.Count; int index = 0; DateTime start = DateTime.MinValue; //DateTime breakTime = DateTime.Now + m_BreakTime; //int saves = World.m_Saves; while (index < m_BreakCount && m_Queue.Count != 0) { Timer t = (Timer)m_Queue.Dequeue(); TimerProfile prof = t.GetProfile(); if (prof != null) { start = DateTime.UtcNow; } t.OnTick(); t.m_Queued = false; ++index; if (prof != null) { prof.RegTicked(DateTime.UtcNow - start); } /*if ( saves == World.m_Saves && DateTime.Now >= breakTime ) * { * Console.WriteLine( "Timer stall detected, dumping timers" ); * * using ( StreamWriter sw = new StreamWriter( "timerdump_stall.log", true ) ) * { * sw.WriteLine( "PROBLEM TIMER: {0}", t ); * Timer.DumpInfo( sw ); * } * * break; * }*/ } //while !empty } }
internal void Tick() { TimerProfile prof = this.GetProfile(); DateTime start = DateTime.MinValue; if (prof != null) { start = DateTime.Now; } OnTick(); if (prof != null) { prof.RegTicked(DateTime.Now - start); } }
public static void Slice() { lock ( m_Queue ) { m_QueueCountAtSlice = m_Queue.Count; int index = 0; Stopwatch watch = null; while (index < m_BreakCount && m_Queue.Count != 0) { Timer t = m_Queue.Dequeue(); TimerProfile prof = t.GetProfile(); if (prof != null) { if (watch == null) { watch = Stopwatch.StartNew(); } else { watch.Start(); } } t.OnTick(); t.m_Queued = false; ++index; if (prof != null) { prof.RegTicked(watch.Elapsed); watch.Reset(); } } } }