You probably already know the class DispatcherTimer who, by definition, is :

A timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.

So, we can launch a task every 100ms if we want. Great. In my case, I want to start a specific method every 100ms during 30 seconds (300 cycles). Too easy ! I just need to initialize a counter and to increment it each time the method is launch. Just to be sure, I check the time of all the process by using the class Stopwatch and … it doesn’t take 30 seconds to do this but a little much more.

dispatchertimer_test

We can see a huge difference between the estimated time (DispatcherTimer) and the real time calculate by the stopwatch.

In conclusion, don’t use the interval of time if you need a precise timer.

Source