Class TimerHelper
Offers some helper methods for timed operations.
Inherited Members
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class TimerHelper
Properties
| Edit this page View SourceUseHighResolutionTimers
Gets or sets if High Resolution Timers should be used.
Declaration
public static bool UseHighResolutionTimers { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceDisposeAllHighResolutionTimerRequests()
Disposes all open High Resolution Timer Requests. This should be called once when exiting the application to make sure nothing remains open and the application correctly unregisters itself on OS level. Shouldn't be needed if everything is disposed, but better safe then sorry.
Declaration
public static void DisposeAllHighResolutionTimerRequests()
Execute(Action, double)
Executes the provided action and blocks if needed until the the
Declaration
public static double Execute(Action action, double targetExecuteTime = 0)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action to execute. |
double | targetExecuteTime | The time in ms this method should block. default: 0 |
Returns
Type | Description |
---|---|
double | The time in ms spent executing the |
GetElapsedTime(long)
Calculates the elapsed time in ms from the provided timestamp until now.
Declaration
public static double GetElapsedTime(long initialTimestamp)
Parameters
Type | Name | Description |
---|---|---|
long | initialTimestamp | The initial timestamp to calculate the time from. |
Returns
Type | Description |
---|---|
double | The elapsed time in ms. |
RequestHighResolutionTimer()
Requests to use to use High Resolution Timers if enabled. IMPORTANT: Always dispose the returned disposable if High Resolution Timers are no longer needed for the caller.
Declaration
public static IDisposable RequestHighResolutionTimer()
Returns
Type | Description |
---|---|
IDisposable | A disposable to remove the request. |