Class TaskExtensions
Defines a collection of extensions for tasks.
public static class TaskExtensions
- Inheritance
-
TaskExtensions
- Inherited Members
Methods
AndObserveExceptions(Task, Action<Exception>?)
Observes the exceptions of faulted tasks.
public static Task AndObserveExceptions(this Task task, Action<Exception>? onException = null)
Parameters
taskTaskThe task to observe for exceptions.
onExceptionAction<Exception>An action invoked when an exception is caught.
Returns
- Task
An asynchronous operation.
Exceptions
- Exception
Potentially thrown by the
onExceptiondelegate callback.
AndObserveExceptions<T>(Task<T>, Action<Exception>?)
Observes the exceptions of faulted tasks.
public static Task<T> AndObserveExceptions<T>(this Task<T> task, Action<Exception>? onException = null)
Parameters
taskTask<T>The task to observe for exceptions.
onExceptionAction<Exception>An action invoked when an exception is caught.
Returns
- Task<T>
An asynchronous operation.
Type Parameters
TThe instance type for the listener.
Exceptions
- Exception
Potentially thrown by the
onExceptiondelegate callback.
WhenAll(IEnumerable<Task>)
Creates a task that will complete when all of the Task objects in the collection have completed.
public static Task WhenAll(this IEnumerable<Task> tasks)
Parameters
tasksIEnumerable<Task>The tasks to wait on for completion.
Returns
- Task
A task that represents the completion of all of the supplied tasks.
WhenAny(IEnumerable<Task>)
Creates a task that will complete when any of the Task objects in the collection have completed.
public static Task WhenAny(this IEnumerable<Task> tasks)
Parameters
tasksIEnumerable<Task>The tasks to wait on for completion.
Returns
- Task
A task that represents the completion of one of the supplied tasks.