File Timer.cs

namespace axr
namespace sdk
namespace Utils
class Timer

The Timer class provides an interface for queuing tasks for execution after a given delay. More than one timer or interval can be scheduled at a time, however calling Clear() on the timer instance will stop all scheduled timers simultaneously.

Public Functions

Timer (CancellationToken cts, ILogger logger)
void Clear ()

Clears the active timer, halting any current operation.

void SetInterval (Action func, int interval)

Sets an interval timer and begins execution for the given time interval. Calls the given function on every elapsed interval.

Param func

<The function to call at every interval./param>

Param interval

The time, in milliseconds, of the interval.

void SetTimeout (Action func, int interval)

Sets a timer to execute a given function after the specified amount of time has elapsed.

Param func

The function to call once the set time as elapsed.

Param interval

The time, in milliseconds, to wait before the task will be executed.

Private Members

CancellationToken _cts
ILogger _logger
bool _stopping