1

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
xcoder37
  • 499
  • 6
  • 21

2 Answers2

1

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

Community
  • 1
  • 1
Lukkha Coder
  • 4,421
  • 29
  • 25
  • If 30 fps is default for Windows Phone 8.1, resolution higher than around 33 ms is indeed pointless. However my app has very unusual scenario. I use Dispatcher Timer to probe pointer position and to detect position changes (currenly I'm working on desktop environment so in fact for now my pointer is mouse cursor) I can't call Window.Current.CoreWindow.PointerPosition on other thread than dispatcher's and I'm, not sure if UIElement.PointerMoved event is deterministic, so I decided to probe cursor at fixed intervals. – xcoder37 Jul 28 '15 at 08:23
  • However, if resolution of DispatcherTimer was corelated with FPS of the device, Windows.UI.Core.CoreDispatcher.RunAsync() should also be able to fire action passed as a parameter only around 30 times a second. But it doesn't behave that way, which is sttange for me. – xcoder37 Jul 29 '15 at 16:59
0

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

CraicDesign
  • 631
  • 6
  • 5