This timer is as precise as the platform you are running it on down to 1 millisecond.
PrecisionTimer.NET won't randomly dispose itself, You don't need to keep a special reference to it.
If you intend to use a lot of timers or you want to use PrecisionTimer.NET to repeat a long running task, consider using Timer Sink.NET
using PrecisionTiming;
public static PrecisionTimer MyTimer = new();Using Precision Timer is as simple as using any other Windows Timer.
MyTimer.SetInterval(SomeAction, Interval);Start the Timer
MyTimer.Start();Check if the Timer is Running
MyTimer.IsRunning();Stop the Timer
MyTimer.Stop();Dispose the Timer
MyTimer.Dispose();If you use SetInterval to set only Action and Interval the timer will automatically start with the most common defaults, but it has several optional parameters you can change
For example, If you don't want the timer to start automatically then use the following
MyTimer.SetInterval(SomeAction, Interval, false);You can use Configure instead of SetInterval if you prefer
MyTimer.Configure(SomeAction, Interval, false);You can manually configure the Timer and then Start it yourself instead of using SetInterval
Sets the Action that will be triggered by the TimerCallback when the Period has elapsed
MyTimer.SetAction(Action);Periodic Timers must stop before setting.
Sets the Period (Interval) between Actions in Milliseconds.
MyTimer.SetPeriod(int);MyTimer.GetPeriod();Both Timer Modes must stop before setting.
Set the Resolution of the Timer
MyTimer.SetResolution(int);MyTimer.GetResolution();The resolution is in milliseconds, The default resolution for SetInterval(Action) is 0
The Resolution increases with smaller values.
A resolution of 0 indicates periodic events should occur with the greatest possible accuracy.
To reduce system overhead, however, you should use the maximum value appropriate for your application.
The normal Resolution of a .Net Timer is around 12-15ms
Both Timer Modes must stop before setting.
Set EventArgs of the Timer
MyTimer.SetEventArgs(EventArgs);MyTimer.GetEventArgs();Periodic Timers must stop before setting.
Set the Periodic/OneShot Mode of the
MyTimer.SetAutoResetMode(bool);MyTimer.GetAutoResetMode();True if the PrecisionTimer should raise the Ticks Event each time the interval elapses. (Periodic)
False if the PrecisionTimer should raise the event only once AFTER the first time the interval elapses. (One-Shot)
Both Timer Modes must stop before setting.
Global Multimedia Timer settings that affect your application
Set the Applications Minimum Resolution
PrecisionTimerSettings.SetMinimumTimerResolution(0);Clear the Applications Minimum Resolution
PrecisionTimerSettings.ClearMinimumTimerResolution(0);Precision Timer.NET is a Multimedia Timer.
You can read more about Multimedia Timers on MSDN
Consider using Timer Sink.NET instead of using PrecisionTimer.NET directly

