Skip to content

Timer Class

A simple timer with callback.

C#
public class Timer : UpdateComponent, IComponent

Inheritance objectUpdateComponent

Implements IComponent

Creates a new timer.

C#
public Timer(TimeSpan triggerTime)

triggerTime TimeSpan
Duration of the timer.

If true, the timer will restart when the time has elapsed.

C#
public bool Repeat { get; set; }

How many milliseconds to cause the timer to trigger.

C#
public TimeSpan TimerAmount { get; set; }

When true, indicates that the timer is running; otherwise false.

C#
public bool IsRunning { get; protected set; }

Updates the timer with the time since the last call.

C#
public override void Update(IScreenObject console, TimeSpan delta)

console IScreenObject
The parent object.

delta TimeSpan
The time since the last frame update.

Restarts the timer; raises the TimerRestart event.

C#
public void Restart()

Starts the timer; raises the TimerStart event.

C#
public void Start()

Starts the timer; raises the TimerStop event.

C#
public void Stop()

Called when the timer elapses.

C#
public event EventHandler? TimerElapsed

EventHandler

Called when the timer restarts.

C#
public event EventHandler? TimerRestart

EventHandler

Called when the timer starts.

C#
public event EventHandler? TimerStart

EventHandler

Called when the timer stops.

C#
public event EventHandler? TimerStop

EventHandler