Class TaskAwaiting
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides functions for awaiting tasks.
public static class TaskAwaiting
- Inheritance
-
TaskAwaiting
- Inherited Members
Methods
WaitAll(IAsyncEnumerable<Task>)
Awaits enumeration of the entire IAsyncEnumerable<T> and awaits all tasks.
public static Task WaitAll(this IAsyncEnumerable<Task> tasks)
Parameters
tasksIAsyncEnumerable<Task>The tasks to await. The collection will be enumerated.
Returns
Remarks
The implementation uses the ToListAsync<T>(IAsyncEnumerable<T>) method to first ensure all the elements are enumerated, forcing all tasks to be initialized, if they haven't already been. If this behavior is undesirable, consider using the WaitAllIteratively(IAsyncEnumerable<Task>) method.
WaitAll(IEnumerable<Task>)
Awaits all tasks in the provided collection.
public static Task WaitAll(this IEnumerable<Task> tasks)
Parameters
tasksIEnumerable<Task>The tasks to await. The collection will be enumerated.
Returns
WaitAllIteratively(IAsyncEnumerable<Task>)
Awaits enumeration of the entire IAsyncEnumerable<T> and awaits all tasks.
public static Task WaitAllIteratively(this IAsyncEnumerable<Task> tasks)
Parameters
tasksIAsyncEnumerable<Task>The tasks to await. The collection will be enumerated.
Returns
Remarks
The implementation first awaits iteration to the next element in the IAsyncEnumerable<T> and then awaits the yielded Task, without guaranteeing that all tasks have been initialized and are simultaneously running on the background before their yielding. If this behavior is undesirable, consider using the WaitAll(IAsyncEnumerable<Task>) method.