TplExtensions.WithTimeout Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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. |
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
Visual Studio SDK 2022 i druge verzije
Proizvod | Verzije |
---|---|
Visual Studio SDK | 2015, 2017, 2019, 2022 |
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
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 |