In researching options for getting better than the 15 ms resolution provided by .NET timer objects (see https://stackoverflow.com/questions/3744032/why-are-net-timers-limited-to-15-ms-resolution), I am looking at the different timer objects that Windows provides. I have identified the following:
Are there other timer types available in the Windows API?
I asked this question because I was interested in implementing a periodic timer that would give me better granularity than the timers that are supplied with .NET. My investigation of those timers (Windows.Forms.Timer
, System.Timers.Timer
, and System.Threading.Timer
) shows that the best I can hope for is 15 ms granularity, and accuracy of -1 to +30 ms. That's fine for most applications, but not for the application I was working on.
For details of my investigation, see Why are .NET timers limited to 15 ms resolution? and http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=815.
That led me to looking for periodic timer objects available under Windows. I identified the five types that I posted in the original question. I didn't find any others. I discarded the old-style Windows timer because I don't want to be processing messages. I then wrote managed prototypes in C# for the other four timer types and did some testing.
All four timer types (Multimedia timers, Waitable timers, Timer queue timers, and Threadpool timers) give a reliable 1 ms interval, with very good resolution. Of those, the Threadpool timer is by far the easiest to interact with, but unfortunately it's not supported on Windows XP. Timer queue timers have a dizzying array of options, but if you ignore most of the options they're almost as simple as Threadpool timers. See Exploring options for better timers for more info.
I chose to wrap the timer queue timer for my general timer class in .NET. You can see it here.
You might also be interested in Waitable Timers in .NET with C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With