Show / Hide Table of Contents

Class TimerHelper

Offers some helper methods for timed operations.

Inheritance
object
TimerHelper
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class TimerHelper

Properties

| Edit this page View Source

UseHighResolutionTimers

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 Source

DisposeAllHighResolutionTimerRequests()

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()
| Edit this page View Source

Execute(Action, double)

Executes the provided action and blocks if needed until the the has passed.

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 .

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX