Table of Contents

Method RunFor

Namespace
KZDev.PrimeTime.Testing
Assembly
KZDev.PrimeTime.Testing.dll

RunFor(Duration)

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.

bool RunFor(Duration duration)

Parameters

duration Duration

Virtual elapsed time after which the bounded run stops.

Returns

bool

true if the bounded run started; false if 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(Duration, Duration). For synchronous deterministic marching, use Advance(Duration).

RunFor(Duration, Duration)

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.

bool RunFor(Duration duration, Duration perSecondRate)

Parameters

duration Duration

Virtual elapsed time after which the bounded run stops.

perSecondRate Duration

Virtual time that elapses per one real second.

Returns

bool

true if the bounded run started; false if 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 perSecondRate is outside the inclusive range allowed for Start(Duration?).

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.

bool RunFor(TimeSpan duration)

Parameters

duration TimeSpan

Virtual elapsed time after which the bounded run stops.

Returns

bool

true if the bounded run started; false if 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.

bool RunFor(TimeSpan duration, TimeSpan perSecondRate)

Parameters

duration TimeSpan

Virtual elapsed time after which the bounded run stops.

perSecondRate TimeSpan

Virtual time that elapses per one real second.

Returns

bool

true if the bounded run started; false if 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 perSecondRate is outside the inclusive range allowed for Start(TimeSpan?) (100 milliseconds to 1 hour of virtual time per real second).