private CountAction MeasureTotalTicks(TimerTrigger trigger, int msToRun) { CountAction action = new CountAction(); trigger.Actions.Add(action); trigger.StartTimer(); DateTime currentTime = DateTime.Now; DateTime stopTime = currentTime.AddMilliseconds(msToRun); while (DateTime.Now.CompareTo(stopTime) < 0) { DispatcherHelper.ClearFrames(Dispatcher.CurrentDispatcher); } return(action); }