Timer Class
Definition
Section titled “Definition”A simple timer with callback.
public class Timer : UpdateComponent, IComponentInheritance object → UpdateComponent
Implements IComponent
Constructors
Section titled “Constructors”Timer(TimeSpan)
Section titled “Timer(TimeSpan)”Creates a new timer.
public Timer(TimeSpan triggerTime)Parameters
Section titled “Parameters”triggerTime TimeSpan
Duration of the timer.
Properties
Section titled “Properties”Repeat
Section titled “Repeat”If true, the timer will restart when the time has elapsed.
public bool Repeat { get; set; }TimerAmount
Section titled “TimerAmount”How many milliseconds to cause the timer to trigger.
public TimeSpan TimerAmount { get; set; }IsRunning
Section titled “IsRunning”When true, indicates that the timer is running; otherwise false.
public bool IsRunning { get; protected set; }Methods
Section titled “Methods”Update(IScreenObject, TimeSpan)
Section titled “Update(IScreenObject, TimeSpan)”Updates the timer with the time since the last call.
public override void Update(IScreenObject console, TimeSpan delta)Parameters
Section titled “Parameters”console IScreenObject
The parent object.
delta TimeSpan
The time since the last frame update.
Restart()
Section titled “Restart()”Restarts the timer; raises the TimerRestart event.
public void Restart()Start()
Section titled “Start()”Starts the timer; raises the TimerStart event.
public void Start()Stop()
Section titled “Stop()”Starts the timer; raises the TimerStop event.
public void Stop()Events
Section titled “Events”TimerElapsed
Section titled “TimerElapsed”Called when the timer elapses.
public event EventHandler? TimerElapsedEvent Type
Section titled “Event Type”TimerRestart
Section titled “TimerRestart”Called when the timer restarts.
public event EventHandler? TimerRestartEvent Type
Section titled “Event Type”TimerStart
Section titled “TimerStart”Called when the timer starts.
public event EventHandler? TimerStartEvent Type
Section titled “Event Type”TimerStop
Section titled “TimerStop”Called when the timer stops.
public event EventHandler? TimerStop