Class ITimeServiceExtensions
Extension methods for ITimeService.
public static class ITimeServiceExtensions
- Inheritance
-
ITimeServiceExtensions
- Inherited Members
Methods
DelayAsync(ITimeService, int)
Creates a task that completes after a specified time interval.
public static Task DelayAsync(this ITimeService timeService, int millisecondsDelay)
Parameters
timeService
ITimeServiceThe ITimeService.
millisecondsDelay
intThe number of milliseconds to wait before completing the returned task, or -1 to wait indefinitely.
Returns
- Task
A task that represents the time delay.
Exceptions
- ArgumentNullException
timeService
is null.- ArgumentOutOfRangeException
millisecondsDelay
is a negative value other than -1, or it represents a time span that is greater than MaxDelay.
DelayAsync(ITimeService, int, CancellationToken)
Creates a cancellable task that completes after a specified time interval.
public static Task DelayAsync(this ITimeService timeService, int millisecondsDelay, CancellationToken cancellationToken)
Parameters
timeService
ITimeServiceThe ITimeService.
millisecondsDelay
intThe number of milliseconds to wait before completing the returned task, or -1 to wait indefinitely.
cancellationToken
CancellationTokenThe cancellation token that will be checked prior to completing the returned task.
Returns
- Task
A task that represents the time delay.
Exceptions
- ArgumentNullException
timeService
is null.- ArgumentOutOfRangeException
millisecondsDelay
is a negative value other than -1, or it represents a time span that is greater than MaxDelay.
StartNewTimeoutTimer(ITimeService, TimeSpan)
Initializes a new timeout timer instance and starts measuring elapsed time.
public static ITimeoutTimer StartNewTimeoutTimer(this ITimeService timeService, TimeSpan duration)
Parameters
timeService
ITimeServiceThe ITimeService.
duration
TimeSpanThe timeout duration.
Returns
- ITimeoutTimer
A ITimeoutTimer that has just begun measuring elapsed time.
Exceptions
- ArgumentNullException
timeService
is null.- ArgumentOutOfRangeException
duration
is greater than MaxDelay or represents a negative time interval.