Udostępnij za pośrednictwem


TplExtensions.WithTimeout Method

Definition

Overloads

WithTimeout(Task, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

WithTimeout<T>(Task<T>, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

WithTimeout(Task, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task ^ WithTimeout(System::Threading::Tasks::Task ^ task, TimeSpan timeout);
public static System.Threading.Tasks.Task WithTimeout (this System.Threading.Tasks.Task task, TimeSpan timeout);
static member WithTimeout : System.Threading.Tasks.Task * TimeSpan -> System.Threading.Tasks.Task
<Extension()>
Public Function WithTimeout (task As Task, timeout As TimeSpan) As Task

Parameters

task
Task

The task to wait for.

timeout
TimeSpan

The maximum time to wait.

Returns

A task that completes with the result of the specified task or faults with a TimeoutException if timeout elapses first.

Applies to

WithTimeout<T>(Task<T>, TimeSpan)

Returns a task that completes as the original task completes or when a timeout expires, whichever happens first.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<T> ^ WithTimeout(System::Threading::Tasks::Task<T> ^ task, TimeSpan timeout);
public static System.Threading.Tasks.Task<T> WithTimeout<T> (this System.Threading.Tasks.Task<T> task, TimeSpan timeout);
static member WithTimeout : System.Threading.Tasks.Task<'T> * TimeSpan -> System.Threading.Tasks.Task<'T>
<Extension()>
Public Function WithTimeout(Of T) (task As Task(Of T), timeout As TimeSpan) As Task(Of T)

Type Parameters

T

The type of value returned by the original task.

Parameters

task
Task<T>

The task to wait for.

timeout
TimeSpan

The maximum time to wait.

Returns

Task<T>

A task that completes with the result of the specified task or faults with a TimeoutException if timeout elapses first.

Applies to