Click or drag to resize
TaskExtensionsWithTimeout Method (Task, TimeSpan)
Wraps a Task with a new Task which will throw a TimeoutException if the original Task takes longer than a specified amount of time to complete.

Namespace: CodeTiger.Threading.Tasks
Assembly: CodeTiger.Core (in CodeTiger.Core.dll) Version:
public static Task WithTimeout(
	this Task task,
	TimeSpan timeout


Type: System.Threading.TasksTask
The original task.
Type: SystemTimeSpan
The maximum amount of time to wait for task to complete.

Return Value

Type: Task
A new Task which wraps task, or just task if either timeout is equal to InfiniteTimeSpan or task has already completed.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Task. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
TimeoutExceptionThrown when task takes longer than the specified amount of time to complete.
See Also