0

What is the best-performing, free-threaded timer for Windows Desktop, either managed or native? I am looking for the best precision and lowest "tick" callback latency. I thought CreateWaitableTimer/SetWaitableTimer might be the best: How To Use a Waitable Timer with an Asynchronous Procedure Call, but I am not sure.

avo
  • 10,101
  • 13
  • 53
  • 81
  • *Managed* timer is either of [these](http://stackoverflow.com/questions/1416803/system-timers-timer-vs-system-threading-timer). I have no idea about native (managed timer is a wrapper for sure, perhaps it even uses waitable timer itself). If you need very low latency, then you have to write a driver. Precision is achieved by synchronization and it doesn't matter which timer you use (you can even have own `while` loop). – Sinatr Feb 05 '14 at 14:29
  • 1
    "Best performing" is way to ambiguous. CreateTimerQueueTimer() is generally advisable. Also used in .NET since v4.5 – Hans Passant Feb 05 '14 at 14:31
  • 1
    _...best precision and lowest "tick" callback latency._: native [Waitable Timer Objects](http://msdn.microsoft.com/en-us/library/windows/desktop/ms687012%28v=vs.85%29.aspx)! – Arno Feb 05 '14 at 14:58

1 Answers1

1

There is a number of articles describing .NET timers: MSDN detailed description, short table of differences, and CodeProject testing of timers. The main difference between them isn't performance or precision (it is ~0.01s for all, but Windows isn't a real-time OS, so precision can't be guaranteed), but the characteristics described in the second link I provided and explained in more details in other articles.

Sasha
  • 8,537
  • 4
  • 49
  • 76