Class TimerLoopTicker<TState>
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
periodicDelayTimeSpanHow often to invoke the timer.
loggerILoggerinvokeImmediatelyboolIf the timer should be invoked now or wait a period.
stateTStatequeueOnGameThreadboolCallback will always be fired on the game thread (if it exists).
onTickTickerCallback<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
initialDelayTimeSpanHow long to wait to initially invoke the timer.
loggerILoggerperiodicDelayTimeSpanHow often to invoke the timer.
stateTStatequeueOnGameThreadboolCallback will always be fired on the game thread (if it exists).
onTickTickerCallback<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
PeriodicDelay
Delay between each subsequent invocation.
public TimeSpan PeriodicDelay { get; }
Property Value
QueueOnGameThread
The callback will always be fired on the main thread if it exists.
public bool QueueOnGameThread { get; }
Property Value
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>>