Method Amb
View SourceAmb<TSource>(IAsyncEnumerable<TSource>, params IAsyncEnumerable<TSource>[])
Propagates the async-enumerable sequence that reacts first.
Declaration
public static IAsyncEnumerable<TSource> Amb<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> | An async-enumerable sequence that surfaces whichever sequence returned first. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequences |
Remarks
The implementation of this method is deeply unfair with regards to the ordering of the input sequences. The
sequences are initialized in the order in which they are received. This means that earlier sequences will have
an opportunity to finish sooner, meaning that all other things being equal, the earlier a sequence is (where
source
precedes any sequence in otherSources
), the more likely it will be
chosen by this operator. Additionally, the first sequence to return the first element of the sequence
synchronously will be chosen.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Amb<TSource>(IEnumerable<IAsyncEnumerable<TSource>>)
Propagates the async-enumerable sequence that reacts first.
Declaration
public static IAsyncEnumerable<TSource> Amb<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
The implementation of this method is deeply unfair with regards to the ordering of the sources
. The sequences in sources
are initialized in the order in which they are
received. This means that earlier sequences will have an opportunity to finish sooner, meaning that all other
things being equal, the earlier a sequence is in sources
, the more likely it will be chosen
by this operator. Additionally, the first sequence to return the first element of the sequence synchronously
will be chosen.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|