Class TaskHelper
Inherited Members
Namespace:Microsoft.DocAsCode.Utility
Assembly:Microsoft.DocAsCode.Utility.dll
Syntax
public static class TaskHelper
Fields
| Improve this Doc View SourceCompleted
A completed task
Declaration
public static readonly Task Completed
Field Value
Type | Description |
---|---|
Task |
Methods
| Improve this Doc View SourceForEachInParallelAsync<T>(IEnumerable<T>, Func<T, Task>)
Provide parallel version for ForEach
Declaration
public static Task ForEachInParallelAsync<T>(this IEnumerable<T> source, Func<T, Task> body)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable to control the foreach loop |
Func<T, Task> | body | The task body |
Returns
Type | Description |
---|---|
Task | The task |
Type Parameters
Name | Description |
---|---|
T | The type for the enumerable |
Remarks
The max parallelism is 64.
ForEachInParallelAsync<T>(IEnumerable<T>, Func<T, Task>, Int32)
Provide parallel version for ForEach
Declaration
public static Task ForEachInParallelAsync<T>(this IEnumerable<T> source, Func<T, Task> body, int maxParallelism)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable to control the foreach loop |
Func<T, Task> | body | The task body |
Int32 | maxParallelism | The max parallelism allowed |
Returns
Type | Description |
---|---|
Task | The task |
Type Parameters
Name | Description |
---|---|
T | The type for the enumerable |
SelectInParallelAsync<TSource, TResult>(IEnumerable<TSource>, Func<TSource, Task<TResult>>)
Provide parallel version for Select that each element will map to a result
Declaration
public static Task<IReadOnlyList<TResult>> SelectInParallelAsync<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, Task<TResult>> body)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The enumerable to control the select |
Func<TSource, Task<TResult>> | body | The select body |
Returns
Type | Description |
---|---|
Task<IReadOnlyList<TResult>> | The task |
Type Parameters
Name | Description |
---|---|
TSource | The type for the enumerable |
TResult | The type for the result |
Remarks
The max parallelism is 64.
SelectInParallelAsync<TSource, TResult>(IEnumerable<TSource>, Func<TSource, Task<TResult>>, Int32)
Provide parallel version for Select that each element will map to a result
Declaration
public static Task<IReadOnlyList<TResult>> SelectInParallelAsync<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, Task<TResult>> body, int maxParallelism)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | The enumerable to control the select |
Func<TSource, Task<TResult>> | body | The select body |
Int32 | maxParallelism | The max parallelism allowed |
Returns
Type | Description |
---|---|
Task<IReadOnlyList<TResult>> | The task |
Type Parameters
Name | Description |
---|---|
TSource | The type for the enumerable |
TResult | The type for the result |