Class IAsyncEnumerableExtensions
Extension methods for IAsyncEnumerable<T> types.
Inherited Members
Namespace: Microsoft.GNS.Roster.Extensions
Assembly: Microsoft.XboxStudios.SQTech.Roster.Common.dll
Syntax
public static class IAsyncEnumerableExtensions
Methods
View SourceIterateWhileAwaitAsync<T>(IAsyncEnumerable<T>, Func<T, Task<bool>>, CancellationToken)
Performs a function on each item in an enumeration using async tasks in a task pool safe manner.
Declaration
public static Task<bool> IterateWhileAwaitAsync<T>(this IAsyncEnumerable<T> source, Func<T, Task<bool>> func, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The collection to iterate on. |
Func<T, Task<bool>> | func | The function to call for each item. Return true to continue execution. False to terminate further loops. |
CancellationToken | cancellationToken | An optional cancellation token source for early termination. |
Returns
Type | Description |
---|---|
Task<bool> | True if iteration is intentionally terminated. Otherwise false. |
Type Parameters
Name | Description |
---|---|
T | The type to enumerate. |
SynchronousForEachAwaitAsync<T>(IAsyncEnumerable<T>, Func<T, Task>, CancellationToken)
Performs a function on each item in an async enumeration using async tasks in a task pool safe manner.
Declaration
public static Task SynchronousForEachAwaitAsync<T>(this IAsyncEnumerable<T> source, Func<T, Task> func, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<T> | source | The collection to iterate on. |
Func<T, Task> | func | The function to call for each item. |
CancellationToken | cancellationToken | An optional cancellation token source for early termination. |
Returns
Type | Description |
---|---|
Task | A task representing the work iterating over the source collection. |
Type Parameters
Name | Description |
---|---|
T | The type to enumerate. |