Reputation: 527
I'm writing a Windows 10 Universal App in C#/XAML.
I make use of DispatcherTimer
class, and I'm wondering what's its resolution. I'm doing tests in desktop environment - when I set set the Interval property to value less than 33 milliseconds it seems not to affect the timer - the tick event still fires as often as if Interval was set to 33 miliseconds (around 33 times per second).
Is this behaviour by design (you can't fire a DispatcherTimer
more often than 33 times per second) or does it depend on App's working environment - like device/processor/memory etc. - and my environment simply doesn't support higher timer resolution?
Upvotes: 1
Views: 652
Reputation: 631
DispatcherTimer just queues callbacks on the UI thread. Even if it were to use a high resolution timer under the hood, it would have unavoidable jitter due to random UI activity.
If the intended use is for continuous drawing, you should use a SwapChainPanel - https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.swapchainpanel.aspx
Upvotes: 0
Reputation: 4460
Although I cannot find official documentation anywhere, what you are observing seems to make sense. 33 times per second is around 30 fps default for Windows Phone 8.1. It would be great to know why you need such a high resolution? Also check: WPF Timer problem… Cannot get correct millisecond tick
Upvotes: 1