Table of Contents

Class Timer

Namespace
Luny
Assembly
Luny.dll

A stateful manager for a countdown or count-up. Supports pausing, time-scaling, and auto-repeat.

public sealed class Timer
Inheritance
object
Timer

Constructors

Timer(double)

Creates a new timer with duration in seconds.

public Timer(double duration)

Parameters

duration double

Properties

AutoRepeat

public bool AutoRepeat { get; set; }

Property Value

bool

Current

public double Current { get; }

Property Value

double

Duration

public double Duration { get; set; }

Property Value

double

IsRunning

public bool IsRunning { get; set; }

Property Value

bool

Progress

Returns the progress as a normalized value (0.0 to 1.0).

public double Progress { get; }

Property Value

double

RemainingMilliseconds

Returns the remaining time in milliseconds.

public double RemainingMilliseconds { get; }

Property Value

double

RemainingMinutes

Returns the remaining time in minutes.

public double RemainingMinutes { get; }

Property Value

double

RemainingSeconds

Returns the remaining time in seconds.

public double RemainingSeconds { get; }

Property Value

double

TimeScale

public double TimeScale { get; set; }

Property Value

double

Methods

FromMilliseconds(double)

Creates a new timer with duration in milliseconds.

public static Timer FromMilliseconds(double ms)

Parameters

ms double

Returns

Timer

FromMinutes(double)

Creates a new timer with duration in minutes.

public static Timer FromMinutes(double minutes)

Parameters

minutes double

Returns

Timer

FromSeconds(double)

Creates a new timer with duration in seconds.

public static Timer FromSeconds(double seconds)

Parameters

seconds double

Returns

Timer

Pause()

Pauses the timer. Does not reset Current time.

public void Pause()

Resume()

Resumes the timer if paused. Does nothing if not paused.

public void Resume()

Start()

Starts or restarts the timer from zero.

public void Start()

Stop()

Stops the timer and resets elapsed time to zero.

public void Stop()

Tick(double)

Advances the timer by the specified delta time, unless paused. Fires OnElapsed if duration is reached.

public void Tick(double deltaTime)

Parameters

deltaTime double

ToString()

public override string ToString()

Returns

string

ToString(string)

Returns the current time formatted as a string using TimeSpan format.

public string ToString(string format)

Parameters

format string

Returns

string

Events

OnElapsed

public event Action OnElapsed

Event Type

Action