Table of Contents

Class TimerLoopTicker<TState>

Namespace
Uncreated.Warfare.Util.Timing
Assembly
Uncreated.Warfare.dll

Uses a system Timer.

public class TimerLoopTicker<TState> : ILoopTicker<TState>, ILoopTicker, IDisposable

Type Parameters

TState
Inheritance
TimerLoopTicker<TState>
Implements
ILoopTicker<TState>
Inherited Members

Remarks

For tests mainly as it works without Unity.

Constructors

TimerLoopTicker(TimeSpan, ILogger, bool, TState?, bool, TickerCallback<ILoopTicker<TState>>?)

Create a new timer.

public TimerLoopTicker(TimeSpan periodicDelay, ILogger logger, bool invokeImmediately, TState? state, bool queueOnGameThread, TickerCallback<ILoopTicker<TState>>? onTick)

Parameters

periodicDelay TimeSpan

How often to invoke the timer.

logger ILogger
invokeImmediately bool

If the timer should be invoked now or wait a period.

state TState
queueOnGameThread bool

Callback will always be fired on the game thread (if it exists).

onTick TickerCallback<ILoopTicker<TState>>

Callback since the timer being invoked now would mean you couldn't subscribe to the event first.

TimerLoopTicker(TimeSpan, ILogger, TimeSpan, TState?, bool, TickerCallback<ILoopTicker<TState>>?)

Create a new timer.

public TimerLoopTicker(TimeSpan initialDelay, ILogger logger, TimeSpan periodicDelay, TState? state, bool queueOnGameThread, TickerCallback<ILoopTicker<TState>>? onTick)

Parameters

initialDelay TimeSpan

How long to wait to initially invoke the timer.

logger ILogger
periodicDelay TimeSpan

How often to invoke the timer.

state TState
queueOnGameThread bool

Callback will always be fired on the game thread (if it exists).

onTick TickerCallback<ILoopTicker<TState>>

Callback since the timer being invoked now would mean you couldn't subscribe to the event first.

Properties

InitialDelay

Delay before the first invocation.

public TimeSpan InitialDelay { get; }

Property Value

TimeSpan

PeriodicDelay

Delay between each subsequent invocation.

public TimeSpan PeriodicDelay { get; }

Property Value

TimeSpan

QueueOnGameThread

The callback will always be fired on the main thread if it exists.

public bool QueueOnGameThread { get; }

Property Value

bool

State

Generic state that can be used to store information.

public TState? State { get; }

Property Value

TState

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~TimerLoopTicker()

protected ~TimerLoopTicker()

Events

OnTick

Invoked every Delay seconds.

public event TickerCallback<ILoopTicker<TState>>? OnTick

Event Type

TickerCallback<ILoopTicker<TState>>