Method DoWhile
DoWhile<TSource>(IAsyncEnumerable<TSource>, Func<bool>)
Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
Declaration
public static IAsyncEnumerable<TSource> DoWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<bool> condition)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | Source sequence to repeat while the condition evaluates true. |
| Func<bool> | condition | Loop condition. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TSource> | Sequence generated by repeating the given sequence until the condition evaluates to false. |
Type Parameters
| Name | Description |
|---|---|
| TSource | Source sequence element type. |
Remarks
condition is evaluated lazily, once at the end of each loop of source.
source is cached via Memoize<TSource>(IAsyncEnumerable<TSource>), so that it
is only iterated once during the first loop. Successive loops will enumerate the cache instead of source.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
DoWhile<TSource>(IAsyncEnumerable<TSource>, Func<ValueTask<bool>>)
Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
Declaration
public static IAsyncEnumerable<TSource> DoWhile<TSource>(this IAsyncEnumerable<TSource> source, Func<ValueTask<bool>> condition)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | Source sequence to repeat while the condition evaluates true. |
| Func<ValueTask<bool>> | condition | Loop condition. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TSource> | Sequence generated by repeating the given sequence until the condition evaluates to false. |
Type Parameters
| Name | Description |
|---|---|
| TSource | Source sequence element type. |
Remarks
condition is evaluated lazily, once at the end of each loop of source.
source is cached via Memoize<TSource>(IAsyncEnumerable<TSource>), so that it
is only iterated once during the first loop. Successive loops will enumerate the cache instead of source.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|