Επεξεργασία

Κοινή χρήση μέσω


Task.WaitAsync Method

Definition

Overloads

WaitAsync(CancellationToken)

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

WaitAsync(TimeSpan)

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

WaitAsync(TimeSpan, 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(TimeSpan, TimeProvider)

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

WaitAsync(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(CancellationToken)

Source:
Task.cs
Source:
Task.cs
Source:
Task.cs

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

public:
 System::Threading::Tasks::Task ^ WaitAsync(System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WaitAsync (System.Threading.CancellationToken cancellationToken);
member this.WaitAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WaitAsync (cancellationToken As CancellationToken) As Task

Parameters

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 cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Wait().

Applies to

WaitAsync(TimeSpan)

Source:
Task.cs
Source:
Task.cs
Source:
Task.cs

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

public:
 System::Threading::Tasks::Task ^ WaitAsync(TimeSpan timeout);
public System.Threading.Tasks.Task WaitAsync (TimeSpan timeout);
member this.WaitAsync : TimeSpan -> System.Threading.Tasks.Task
Public Function WaitAsync (timeout As TimeSpan) As Task

Parameters

timeout
TimeSpan

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

Returns

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

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Wait(TimeSpan).

Applies to

WaitAsync(TimeSpan, CancellationToken)

Source:
Task.cs
Source:
Task.cs
Source:
Task.cs

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

public:
 System::Threading::Tasks::Task ^ WaitAsync(TimeSpan timeout, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WaitAsync (TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.WaitAsync : TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WaitAsync (timeout As TimeSpan, cancellationToken As CancellationToken) As Task

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

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Wait(TimeSpan).

Applies to

WaitAsync(TimeSpan, TimeProvider)

Source:
Task.cs
Source:
Task.cs

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

public:
 System::Threading::Tasks::Task ^ WaitAsync(TimeSpan timeout, TimeProvider ^ timeProvider);
public System.Threading.Tasks.Task WaitAsync (TimeSpan timeout, TimeProvider timeProvider);
member this.WaitAsync : TimeSpan * TimeProvider -> System.Threading.Tasks.Task
Public Function WaitAsync (timeout As TimeSpan, timeProvider As TimeProvider) As Task

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

Exceptions

The timeProvider argument is null.

Applies to

WaitAsync(TimeSpan, TimeProvider, CancellationToken)

Source:
Task.cs
Source:
Task.cs

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

public:
 System::Threading::Tasks::Task ^ WaitAsync(TimeSpan timeout, TimeProvider ^ timeProvider, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WaitAsync (TimeSpan timeout, TimeProvider timeProvider, System.Threading.CancellationToken cancellationToken);
member this.WaitAsync : TimeSpan * TimeProvider * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WaitAsync (timeout As TimeSpan, timeProvider As TimeProvider, cancellationToken As CancellationToken) As Task

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

Exceptions

The timeProvider argument is null.

The cancellation token was canceled. This exception is stored into the returned task.

Applies to