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.

C++
public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task ^ WithTimeout(System::Threading::Tasks::Task ^ task, TimeSpan timeout);

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

Visual Studio SDK 2022 i druge verzije
Proizvod Verzije
Visual Studio SDK 2015, 2017, 2019, 2022

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

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

C++
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<T> ^ WithTimeout(System::Threading::Tasks::Task<T> ^ task, TimeSpan timeout);

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

Visual Studio SDK 2022 i druge verzije
Proizvod Verzije
Visual Studio SDK 2015, 2017, 2019, 2022