Need events to execute on timer events, metronome precision.
Posted
by user295734
on Stack Overflow
See other posts from Stack Overflow
or by user295734
Published on 2010-03-17T14:59:03Z
Indexed on
2010/03/17
15:01 UTC
Read the original article
Hit count: 354
I setup a timer to call an event in my application. The problme is the event execution is being skewed by other windows operations. Ex. openning and window, loading a webpage. I need the event to excute exactly on time, every time.
When i first set up the app, used a sound file, like a metronome to listen to the even firing, in a steady state, its firing right on, but as soon do something in the windows environment, the sound fires slower, then sort of sppeds up a bit to catch up.
So i added a logging method to the event to ctahc the timer ticks. From that data, it appears that the timer is not being affected by the windows app, but my application event calls are being affected. I figured this out by checking the datetime.now in the event, and if i set it to 250 milliseconds, which is 4 clicks per second. You get data something like below.
(sec):(ms)
1:000 1:250 1:500 1:750
2:000 2:250 2:500 2:750
3:000 3:250 3:500 3:750
(lets say i execute some windows event)(time will skew)
4:122 4:388 4:600 4:876
(stop doing what i was doing in windows) (going to shorten the data for simplicit, my list was 30sec long)
5:124 5:268 5:500 5:750
(you would se the time go back the same milliseconds it was at the begining)
6:000 6:250 6:500 6:750
7:000 7:250 7:500 7:750
So i'm thinking the timer continues to fire on the same millisecond every time, but its the event that is being skewed to fire off time by other windows operations. Its not a huge skew, but for what i need to accomplish, its unacceptable.
Is there anyhting i can do in .NET, hoping to use XAML/WPF application, thats will correct the skewing of events?
thx.
© Stack Overflow or respective owner