Class FrameTimer
FrameTimer is a utility class that allows you to run an action after a specified delay, with the option to repeat it a certain number of times.
public class FrameTimer
- Inheritance
-
FrameTimer
- Inherited Members
- Extension Methods
Properties
Enabled
public bool Enabled { get; }
Property Value
TimeSinceLastRun
Gets the delay between calls. This will not be called more frequently than this delay, but it might be called longer if the delay is greater than the time between frames.
public TimeSpan TimeSinceLastRun { get; }
Property Value
Methods
Initialize(Action, Func<TimeSpan>, int)
Initializes the FrameTimer with a delay generator function.
public FrameTimer Initialize(Action action, Func<TimeSpan> delayGenerator, int runCount = 1)
Parameters
action
ActionThe action to perform after the delay.
delayGenerator
Func<TimeSpan>A function that generates the delay as a TimeSpan.
runCount
intThe number of times to run the action. A negative value will cause the action to run indefinitely.
Returns
- FrameTimer
Returns the FrameTimer instance for method chaining.
Initialize(Action, TimeSpan, int)
public FrameTimer Initialize(Action action, TimeSpan delay, int runCount = 1)
Parameters
action
Actionthe action that is performed
delay
TimeSpanthe delay between calls. This will not be called more frequently than this delay, but it might be called longer if the delay is greater than the time between frames
runCount
intthe amount of times to perform the action. Negative numbers will cause the action to run infinitely
Returns
Start()
Starts the FrameTimer.
public void Start()
Stop()
Stops the FrameTimer.
public void Stop()