Task<TResult>.WaitAsync Method

Definition

Overloads

WaitAsync(TimeSpan, TimeProvider)

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified timeout expires.

WaitAsync(CancellationToken)

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified CancellationToken has cancellation requested.

WaitAsync(TimeSpan)

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified timeout expires.

WaitAsync(TimeSpan, CancellationToken)

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

WaitAsync(TimeSpan, TimeProvider, CancellationToken)

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

WaitAsync(TimeSpan, TimeProvider)

Source:
Future.cs
Source:
Future.cs

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified timeout expires.

C#
public System.Threading.Tasks.Task<TResult> WaitAsync(TimeSpan timeout, TimeProvider timeProvider);

Parameters

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.

Returns

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

Applies to

.NET 10 and other versions
Product Versions
.NET 8, 9, 10

WaitAsync(CancellationToken)

Source:
Future.cs
Source:
Future.cs
Source:
Future.cs

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified CancellationToken has cancellation requested.

C#
public System.Threading.Tasks.Task<TResult> WaitAsync(System.Threading.CancellationToken cancellationToken);

Parameters

cancellationToken
CancellationToken

The CancellationToken to monitor for a cancellation request.

Returns

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

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10

WaitAsync(TimeSpan)

Source:
Future.cs
Source:
Future.cs
Source:
Future.cs

Gets a Task<TResult> that will complete when this Task<TResult> completes or when the specified timeout expires.

C#
public System.Threading.Tasks.Task<TResult> WaitAsync(TimeSpan timeout);

Parameters

timeout
TimeSpan

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

Returns

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

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10

WaitAsync(TimeSpan, CancellationToken)

Source:
Future.cs
Source:
Future.cs
Source:
Future.cs

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

C#
public System.Threading.Tasks.Task<TResult> WaitAsync(TimeSpan timeout, System.Threading.CancellationToken cancellationToken);

Parameters

timeout
TimeSpan

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

cancellationToken
CancellationToken

The CancellationToken to monitor for a cancellation request.

Returns

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

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10

WaitAsync(TimeSpan, TimeProvider, CancellationToken)

Source:
Future.cs
Source:
Future.cs

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

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

Parameters

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<TResult> representing the asynchronous wait. It may or may not be the same instance as the current instance.

Applies to

.NET 10 and other versions
Product Versions
.NET 8, 9, 10