DispatcherTimer
-
Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.
So many years of programming I have forgotten more languages than I know.
-
Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.
So many years of programming I have forgotten more languages than I know.
I should have noted that I can do a simple while loop with a sleep in it and get better results. It still seems like the tick from DispatcherTimer should do better.
So many years of programming I have forgotten more languages than I know.
-
Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.
So many years of programming I have forgotten more languages than I know.
What interval and how far off are we talking? Windows is not a real-time O/S, so getting an exact interval isn't possible. Events or callbacks are guaranteed to occur NO SOONER THAN your interval. That doesn't mean that it will execute ON that interval.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
What interval and how far off are we talking? Windows is not a real-time O/S, so getting an exact interval isn't possible. Events or callbacks are guaranteed to occur NO SOONER THAN your interval. That doesn't mean that it will execute ON that interval.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave KreskowiakI sat the interval for 500 ms. Hard to measure but the trace has a jerky motion. It is much smoother when I use a simple while loop with a sleep in it. Setting the sleep for 20ms gives a nice smooth plot.
So many years of programming I have forgotten more languages than I know.
-
Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.
So many years of programming I have forgotten more languages than I know.
Quote:
Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.
In other words, you need a separate timing device if you want "stability".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
Quote:
Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.
In other words, you need a separate timing device if you want "stability".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
It is probably also effected by the debugger in Visual Studio. It really makes the DispatcherTimer useless for delays under a minute.
So many years of programming I have forgotten more languages than I know.