public TimerCounterContext CreateNewTimerContext (string counterName) { TimerCounter tc = GetCounterByIDOrName (counterName) as TimerCounter; if (tc == null) { throw new Exception ("Unknown timer counter " + counterName); } TimerCounterContext context = new TimerCounterContext { CounterName = counterName, TotalTime = tc.TotalTime }; return context; }
public void WaitForTimerContext (TimerCounterContext context, int timeout = 20000, int pollStep = 200) { TimerCounter tc = GetCounterByIDOrName (context.CounterName) as TimerCounter; if (tc == null) { throw new Exception ("Unknown timer counter " + context.CounterName); } do { if (tc.TotalTime > context.TotalTime) { return; } timeout -= pollStep; Thread.Sleep (pollStep); } while (timeout > 0); throw new TimeoutException ("Timed out waiting for event"); }