Hi,
I have a basic question regarding timers. My timer is acting very strange. I am trying to make the tick occur every millisecond to update my data. I can get it to work with seconds, it seems, but not milliseconds..
I am using WPF and am wondering why the following is not functioning correctly.
It appears that the "second" countdown works correctly, but while using the same procedure and editing one value, it does not "tick" correctly it seems.
I am trying to make a millisecond countdown using the following:
//TimeSpan temp0 = new TimeSpan(0, 0, 0, 0, 1);
CountdownTimer = new DispatcherTimer();
CountdownTimer.Tick += new EventHandler(Countdowntimer_Tick);
CountdownTimer.Interval = TimeSpan.FromSeconds(1.0);//temp0;
The above seems like it works fine for a "second" countdown, but I need more precision, so I do the following:
//TimeSpan temp0 = new TimeSpan(0, 0, 0, 0, 1);
IntroCountdownTimer = new DispatcherTimer();
IntroCountdownTimer.Tick += new EventHandler(Countdowntimer_Tick);
IntroCountdownTimer.Interval = TimeSpan.FromSeconds(0.001);//temp0;
This would give us millisecond precision, BUT, when I try this in my program, it is much much slower. Any ideas why?
void Countdowntimer_Tick(object sender, EventArgs e)
{
m_dIntroCountdown -= 1.0;
}
ps: I do set the "m_dIntroCountdown accordingly. If we are in milliseconds, I set it to 5000.0, if in seconds, 5.0
Maybe I am looking too much into this.. any ideas?
All help is appreciated.
Thanks!