c# - How to ensure timer records at fixed interval? -
i'm trying create windows phone application records accelerometer data @ 100 hz. tried out both system.windows.threading.dispatchertimer
, system.threading.timer
, looking @ data recorded, neither recording @ 100 hz. dispatchertimer
records 60-80 hz, while timer
records @ around 85-90 hz. don't think problem phone not being able handle it, since when tried recording @ 50 hz, still lagging 40+ hz. here snippet of code:
for dispatchertimer
:
timer = new dispatchertimer(); timer.interval = timespan.frommilliseconds(10); timer.tick += new eventhandler(timer_tick);
for timer
:
timer = new timer(timer_tick, null, 0, 10);
how make sure recording @ fixed rate interval?
windows phone 7 - not real-time os. none of timer classes precise. you're doing saying want wait @ least long. takes amount of time fire , end notified timer has ticked once os gets around servicing tick message.
try implement simple test: print current time every 10 milliseconds, , can see minimum error. when developers use 1
or 5
or 10
seconds interval - not noticeable.
Comments
Post a Comment