Show / Hide Table of Contents

Class Timer

A simple timer with callback.

Inheritance
object
UpdateComponent
Timer
Implements
IComponent
Inherited Members
UpdateComponent.OnAdded(IScreenObject)
UpdateComponent.OnRemoved(IScreenObject)
UpdateComponent.SortOrder
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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

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

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
UpdateComponent.Update(IScreenObject, TimeSpan)

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

Implements

IComponent

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX