The .net framework has many ways to use timers, but for a metronome which one should I use ?
I tried all these timers but no one is enough accurate for my use (they can't have a resolution under 15ms).
System.Windows.Forms.Timer
System.Web.UI.Timer
System.Diagnostics.Stopwatch
System.Timers.Timer
System.Threading.Timer
For my metronome class I need Ticks reliable , constant, without drift.
I found this implementation on MSDN : https://msdn.microsoft.com/en-us/library/aa964692(v=vs.85).aspx that use "coredll.dll"
Another solution can be to implement these native methods:
[DllImport("winmm.dll", SetLastError = true, EntryPoint = "timeSetEvent")]
internal static extern UInt32 TimeSetEvent(UInt32 msDelay, UInt32 msResolution, MultimediaTimerCallback callback, ref UInt32 userCtx, UInt32 eventType);
[DllImport("winmm.dll", SetLastError = true, EntryPoint = "timeKillEvent")]
internal static extern void TimeKillEvent(UInt32 uTimerId);
What is the best way to have a timer with a resolution under 5ms on windows ?
EDIT
I found this very interesting link about timers in .net (in french) : http://www.e-naxos.com/Blog/post/NET-et-ses-timers-Prise-de-tete-ou-reelle-utilite-.aspx