c# - DispatcherTimer with interval 0,0,1 is not exactly 1 second? -
(using wpf)
in small application wrote, using count-down timers. have used dispatchertimer
.
counter01 = new dispatchertimer(); counter01.tick += new eventhandler(counter01_tick); counter01.interval = new timespan(0, 0, 1);
but when test/use program, have noticed when it's set (for example) 60 minutes count-down, gets few minutes off compared real world time.
could reason dispatchertimer
not 1 second if use did above?
timers never absolutely exact. after all, it's got run on dispatcher thread - expect happen if dispatcher busy processing other thread @ same time?
it's close enough visibly ticking @ once per second - should take current time , subtract "target" time (or use stopwatch
) fairly-accurate count-down instead of counting number of times timer has ticked.
Comments
Post a Comment