Method ConcurrentMerge
ConcurrentMerge<TSource>(IAsyncEnumerable<TSource>, params IAsyncEnumerable<TSource>[])
Concurrently iterates multiple IAsyncEnumerable<T> and returns elements from each stream in the order in which the iteration completes (which may or may not be in the same order as the sources are provided).
Declaration
public static IAsyncEnumerable<TSource> ConcurrentMerge<TSource>(this IAsyncEnumerable<TSource> source, params IAsyncEnumerable<TSource>[] otherSources)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | The first sequence to merge together |
| IAsyncEnumerable<TSource>[] | otherSources | The other sequences to merge together |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TSource> | A sequence of every element from all source sequences, returned in an order based on how long it takes to iterate each element. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the source sequences |
Remarks
This method is very similar to Interleave<T>(IAsyncEnumerable<T>, params IAsyncEnumerable<T>[]); however, that method executes each iterator sequentially returning each item in a fixed order, while this method executes the iterators in parallel, returning each item as they are received.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentNullException |
|
| ArgumentNullException | Any of the items in |
ConcurrentMerge<TSource>(IEnumerable<IAsyncEnumerable<TSource>>)
Concurrently iterates multiple IAsyncEnumerable<T> and returns elements from each stream in the order in which the iteration completes (which may or may not be in the same order as the sources are provided).
Declaration
public static IAsyncEnumerable<TSource> ConcurrentMerge<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IAsyncEnumerable<TSource>> | sources | The sequence of sequences to merge together |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TSource> | A sequence of every element from all source sequences, returned in an order based on how long it takes to iterate each element. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the source sequences |
Remarks
This method is very similar to Interleave<T>(IAsyncEnumerable<T>, params IAsyncEnumerable<T>[]); however, that method executes each iterator sequentially returning each item in a fixed order, while this method executes the iterators in parallel, returning each item as they are received.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentNullException | Any of the items in |
ConcurrentMerge<TSource>(IEnumerable<IAsyncEnumerable<TSource>>, int)
Concurrently iterates multiple IAsyncEnumerable<T> and returns elements from each stream in the order in which the iteration completes (which may or may not be in the same order as the sources are provided).
Declaration
public static IAsyncEnumerable<TSource> ConcurrentMerge<TSource>(this IEnumerable<IAsyncEnumerable<TSource>> sources, int maxConcurrency)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IAsyncEnumerable<TSource>> | sources | The sequence of sequences to merge together |
| int | maxConcurrency | The maximum number of outstanding iteration operations allowed at any given time. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TSource> | A sequence of every element from all source sequences, returned in an order based on how long it takes to iterate each element. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of the source sequences |
Remarks
This method is very similar to Interleave<T>(IAsyncEnumerable<T>, params IAsyncEnumerable<T>[]); however, that method executes each iterator sequentially returning each item in a fixed order, while this method executes the iterators in parallel, returning each item as they are received.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentNullException | Any of the items in |