Method RunFor
- Namespace
- KZDev.SystemClock.PrimeTime.Testing
- Assembly
- KZDev.SystemClock.PrimeTime.Testing.dll
RunFor(TimeSpan)
Starts a bounded automatic run that advances virtual time by duration at a 1:1
real-time pace (one second of virtual time per real second), then stops when that virtual elapsed time
is reached.
public bool RunFor(TimeSpan duration)
Parameters
durationTimeSpanVirtual elapsed time after which the bounded run stops.
Returns
- bool
trueif the bounded run started;falseif the clock was already running.
Remarks
Returns immediately; wait for completion via IsRunning and/or
ClockStopped. Only starts when the clock is not already running.
Negative duration is treated as zero. Zero duration raises
ClockStarted and ClockStopped
synchronously before returning.
For a faster or slower pace, use RunFor(TimeSpan, TimeSpan). For synchronous deterministic marching, use Advance(TimeSpan).
RunFor(TimeSpan, TimeSpan)
Starts a bounded automatic run that advances virtual time by duration at
perSecondRate (virtual time per one real second), then stops when that virtual elapsed
time is reached.
public bool RunFor(TimeSpan duration, TimeSpan perSecondRate)
Parameters
durationTimeSpanVirtual elapsed time after which the bounded run stops.
perSecondRateTimeSpanVirtual time that elapses per one real second.
Returns
- bool
trueif the bounded run started;falseif the clock was already running.
Remarks
Returns immediately; wait for completion via IsRunning and/or
ClockStopped. Only starts when the clock is not already running.
Negative duration is treated as zero. Zero duration raises
ClockStarted and ClockStopped
synchronously before returning.
Exceptions
- ArgumentOutOfRangeException
Thrown when
perSecondRateis outside the inclusive range allowed for Start(TimeSpan?) (100 milliseconds to 1 hour of virtual time per real second).