ExperimentalEnumerableMergeT(IEnumerableIAsyncEnumerableT, Int32) Method

Concurrently merges all the elements of multiple asynchronous streams into a single asynchronous stream. An additional parameter specifies the maximum concurrent operations that may be in flight at any give time.

Definition

Namespace: MoreLinq.Experimental.Async
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static IAsyncEnumerable<T> Merge<T>(
	this IEnumerable<IAsyncEnumerable<T>> sources,
	int maxConcurrent
)

Parameters

sources  IEnumerableIAsyncEnumerableT
The sequence of asynchronous streams.
maxConcurrent  Int32
Maximum number of asynchronous operations to have in flight at any given time. A value of 1 (or below) disables concurrency.

Type Parameters

T
The type of the elements in sources.

Return Value

IAsyncEnumerableT
An asynchronous stream with all elements from all sources.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableIAsyncEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This operator uses deferred execution and streams its results.

When maxConcurrent is 2 or greater then the elements in the resulting stream may appear in a different order than their order in sources.

When disposed part of the way, there is a best-effort attempt to cancel all iterations that are in flight. This requires that all asynchronous streams in sources properly honour timely cancellation.

See Also