TimeProviderTaskExtensions.WaitAsync Method

Definition

Overloads

WaitAsync(Task, TimeSpan, TimeProvider, CancellationToken)

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

WaitAsync<TResult>(Task<TResult>, TimeSpan, TimeProvider, CancellationToken)

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

WaitAsync(Task, TimeSpan, TimeProvider, CancellationToken)

Source:
TimeProviderTaskExtensions.cs
Source:
TimeProviderTaskExtensions.cs

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

C#
public static System.Threading.Tasks.Task WaitAsync(this System.Threading.Tasks.Task task, TimeSpan timeout, TimeProvider timeProvider, System.Threading.CancellationToken cancellationToken = default);

Parameters

task
Task

The task for which to wait on until completion.

timeout
TimeSpan

The timeout after which the Task should be faulted with a TimeoutException if it hasn't otherwise completed.

timeProvider
TimeProvider

The TimeProvider with which to interpret timeout.

cancellationToken
CancellationToken

The CancellationToken to monitor for a cancellation request.

Returns

The Task representing the asynchronous wait. It may or may not be the same instance as the current instance.

Exceptions

The timeProvider argument is null.

timeout represents a negative time interval other than InfiniteTimeSpan.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

WaitAsync<TResult>(Task<TResult>, TimeSpan, TimeProvider, CancellationToken)

Source:
TimeProviderTaskExtensions.cs
Source:
TimeProviderTaskExtensions.cs

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

C#
public static System.Threading.Tasks.Task<TResult> WaitAsync<TResult>(this System.Threading.Tasks.Task<TResult> task, TimeSpan timeout, TimeProvider timeProvider, System.Threading.CancellationToken cancellationToken = default);

Type Parameters

TResult

Parameters

task
Task<TResult>

The task for which to wait on until completion.

timeout
TimeSpan

The timeout after which the Task should be faulted with a TimeoutException if it hasn't otherwise completed.

timeProvider
TimeProvider

The TimeProvider with which to interpret timeout.

cancellationToken
CancellationToken

The CancellationToken to monitor for a cancellation request.

Returns

The Task representing the asynchronous wait. It may or may not be the same instance as the current instance.

Exceptions

The timeProvider argument is null.

timeout represents a negative time interval other than InfiniteTimeSpan.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)