<PackageReference Include="Polly.Core" Version="8.1.0" />

TimeProviderTaskExtensions

Provide extensions methods for Task operations with TimeProvider.

Initializes a new instance of the CancellationTokenSource class that will be canceled after the specified TimeSpan.

public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, CancellationToken cancellationToken = default)

Creates a task that completes after a specified time interval.

public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken = default)

Gets a Task that will complete when this Task completes, when the specified timeout expires, or when the specified CancellationToken has cancellation requested.

public static Task<TResult> WaitAsync<TResult>(this Task<TResult> task, TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken = default)

Gets a Task that will complete when this Task completes, when the specified timeout expires, or when the specified CancellationToken has cancellation requested.