Class Timer
A simple timer with callback.
Implements
Inherited Members
Namespace: SadConsole.Components
Assembly: SadConsole.dll
Syntax
public class Timer : UpdateComponent, IComponent
Constructors
Timer(TimeSpan)
Creates a new timer.
Declaration
public Timer(TimeSpan triggerTime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | triggerTime | Duration of the timer. |
Properties
IsRunning
Declaration
public bool IsRunning { get; protected set; }
Property Value
Type | Description |
---|---|
bool |
Repeat
If true, the timer will restart when the time has elapsed.
Declaration
public bool Repeat { get; set; }
Property Value
Type | Description |
---|---|
bool |
TimerAmount
How many milliseconds to cause the timer to trigger.
Declaration
public TimeSpan TimerAmount { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
Restart()
Restarts the timer; raises the TimerRestart event.
Declaration
public void Restart()
Start()
Starts the timer; raises the TimerStart event.
Declaration
public void Start()
Stop()
Starts the timer; raises the TimerStop event.
Declaration
public void Stop()
Update(IScreenObject, TimeSpan)
Updates the timer with the time since the last call.
Declaration
public override void Update(IScreenObject console, TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | console | The parent object. |
TimeSpan | delta | The time since the last frame update. |
Overrides
Events
TimerElapsed
Called when the timer elapses.
Declaration
public event EventHandler? TimerElapsed
Event Type
Type | Description |
---|---|
EventHandler |
TimerRestart
Called when the timer restarts.
Declaration
public event EventHandler? TimerRestart
Event Type
Type | Description |
---|---|
EventHandler |
TimerStart
Called when the timer starts.
Declaration
public event EventHandler? TimerStart
Event Type
Type | Description |
---|---|
EventHandler |
TimerStop
Called when the timer stops.
Declaration
public event EventHandler? TimerStop
Event Type
Type | Description |
---|---|
EventHandler |