Which timer to use ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Which timer to use ?

I like to do something every 100 ms. The timer seems to work fine until you count the times it fires. 450 instead of the expected 600. I did expect some inaccuracy but this is a lot. I am using a dispatcher timer because there is some UI work in there too, I can separated that from the things that I really wanted to do, but I want to know. Is there a timer that is better than the dispatcher-timer ? What timer would you use ?

8th Aug 2022, 6:22 PM
sneeze
sneeze - avatar
1 Answer
+ 2
Maybe something make the dispatcher thread busy sometimes and i think that some optimizations must be made .. Anyway try also to set the timer as Send priority https://docs.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatcherpriority?redirectedfrom=MSDN&view=windowsdesktop-6.0
8th Aug 2022, 8:53 PM
KrOW
KrOW - avatar