Show / Hide Table of Contents

Class Extensions

Extensions for operating with System.Threading.Channels.

Inheritance
System.Object
Extensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Open.ChannelExtensions
Assembly: Open.ChannelExtensions.dll
Syntax
public static class Extensions

Methods

| Improve this Doc View Source

AsAsyncEnumerable<T>(ChannelReader<T>, CancellationToken)

Iterates over the results in a ChannelReader. Provided as an alternative to .ReadAllAsync() which at the time of publishing this, only exists in .NET Core 3.0 and not .NET Standard 2.1

Declaration
public static IAsyncEnumerable<T> AsAsyncEnumerable<T>(this ChannelReader<T> reader, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The reader to read from.

System.Threading.CancellationToken cancellationToken

An optional cancellation token that will break out of the iteration.

Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<T>

An IAsyncEnumerable for iterating the channel.

Type Parameters
Name Description
T

The output type of the channel.

| Improve this Doc View Source

AsAsyncEnumerable<TIn, TOut>(Channel<TIn, TOut>, CancellationToken)

Iterates over the results in a Channel. Provided as an alternative to .ReadAllAsync() which at the time of publishing this, only exists in .NET Core 3.0 and not .NET Standard 2.1

Declaration
public static IAsyncEnumerable<TOut> AsAsyncEnumerable<TIn, TOut>(this Channel<TIn, TOut> channel, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TIn, TOut> channel

The reader to read from.

System.Threading.CancellationToken cancellationToken

An optional cancellation token that will break out of the iteration.

Returns
Type Description
System.Collections.Generic.IAsyncEnumerable<TOut>

An IAsyncEnumerable for iterating the channel.

Type Parameters
Name Description
TIn

The type recieved by the source channel.

TOut

The outgoing type from the source channel.

| Improve this Doc View Source

Batch<T>(ChannelReader<T>, Int32, Boolean, Boolean)

Batches results into the batch size provided with a max capacity of batches.

Declaration
public static ChannelReader<List<T>> Batch<T>(this ChannelReader<T> source, int batchSize, bool singleReader = false, bool allowSynchronousContinuations = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> source

The channel to read from.

System.Int32 batchSize

The maximum size of each batch.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Boolean allowSynchronousContinuations

True can reduce the amount of scheduling and markedly improve performance, but may produce unexpected or even undesirable behavior.

Returns
Type Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.List<T>>

A channel reader containing the batches.

Type Parameters
Name Description
T

The output type of the source channel.

| Improve this Doc View Source

CompleteAsync<TWrite, TRead>(Channel<TWrite, TRead>, Exception)

Calls complete on the writer and returns the completion from the reader.

Declaration
public static Task CompleteAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Exception exception = null)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to complete asynchronously.

System.Exception exception

The optional exception to include with completion.

Returns
Type Description
System.Threading.Tasks.Task

The reader's completion task.

Type Parameters
Name Description
TWrite

The type being received by the writer.

TRead

The type being read from the reader.

| Improve this Doc View Source

Filter<T>(ChannelReader<T>, Func<T, Boolean>)

Produces a reader that only contains results that pass the predicate condition. Ones that fail the predicate are discarded.

Declaration
public static ChannelReader<T> Filter<T>(this ChannelReader<T> source, Func<T, bool> predicate)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> source

The source channel reader.

System.Func<T, System.Boolean> predicate

The predicate function.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader representing the filtered results.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

Join<T>(ChannelReader<T[]>, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<T[]> source, bool singleReader = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T[]> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

Join<T>(ChannelReader<IAsyncEnumerable<T>>, Boolean, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<IAsyncEnumerable<T>> source, bool singleReader = false, bool allowSynchronousContinuations = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.IAsyncEnumerable<T>> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Boolean allowSynchronousContinuations

True can reduce the amount of scheduling and markedly improve performance, but may produce unexpected or even undesirable behavior.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

Join<T>(ChannelReader<ICollection<T>>, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<ICollection<T>> source, bool singleReader = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.ICollection<T>> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

Join<T>(ChannelReader<IEnumerable<T>>, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<IEnumerable<T>> source, bool singleReader = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.IEnumerable<T>> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

Join<T>(ChannelReader<IList<T>>, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<IList<T>> source, bool singleReader = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.IList<T>> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

Join<T>(ChannelReader<List<T>>, Boolean)

Joins collections of the same type into a single channel reader in the order provided.

Declaration
public static ChannelReader<T> Join<T>(this ChannelReader<List<T>> source, bool singleReader = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.Collections.Generic.List<T>> source

The source reader.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader containing the joined results.

Type Parameters
Name Description
T

The result type.

| Improve this Doc View Source

OfType<TSource, T>(ChannelReader<TSource>)

Produces a reader that only contains results of a specific type. Others are discarded.

Declaration
public static ChannelReader<T> OfType<TSource, T>(this ChannelReader<TSource> source)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TSource> source

The source channel reader.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

A channel reader representing the filtered results.

Type Parameters
Name Description
TSource

The source item type.

T

The desired item type.

| Improve this Doc View Source

Pipe<TIn, TOut>(ChannelReader<TIn>, Func<TIn, TOut>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> Pipe<TIn, TOut>(this ChannelReader<TIn> source, Func<TIn, TOut> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Func<TIn, TOut> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

Pipe<TIn, TOut>(ChannelReader<TIn>, Int32, Func<TIn, TOut>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> Pipe<TIn, TOut>(this ChannelReader<TIn> source, int maxConcurrency, Func<TIn, TOut> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TIn, TOut> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

Pipe<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Func<TRead, TOut>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> Pipe<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, Func<TRead, TOut> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Func<TRead, TOut> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

Pipe<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Int32, Func<TRead, TOut>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> Pipe<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, int maxConcurrency, Func<TRead, TOut> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TRead, TOut> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

PipeAsync<TIn, TOut>(ChannelReader<TIn>, Func<TIn, ValueTask<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> PipeAsync<TIn, TOut>(this ChannelReader<TIn> source, Func<TIn, ValueTask<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Func<TIn, System.Threading.Tasks.ValueTask<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

PipeAsync<TIn, TOut>(ChannelReader<TIn>, Int32, Func<TIn, ValueTask<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries concurrently and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> PipeAsync<TIn, TOut>(this ChannelReader<TIn> source, int maxConcurrency, Func<TIn, ValueTask<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TIn, System.Threading.Tasks.ValueTask<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

PipeAsync<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Func<TRead, ValueTask<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> PipeAsync<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, Func<TRead, ValueTask<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Func<TRead, System.Threading.Tasks.ValueTask<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

PipeAsync<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Int32, Func<TRead, ValueTask<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> PipeAsync<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, int maxConcurrency, Func<TRead, ValueTask<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TRead, System.Threading.Tasks.ValueTask<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

PipeTo<T>(ChannelReader<T>, Channel<T>, CancellationToken)

Reads all entries from the source channel and writes them to the target. Will call complete when finished and propagates any errors to the channel. This is useful for managing different buffers sizes, especially if the source reader comes from a .Transform function.

Declaration
public static ChannelReader<T> PipeTo<T>(this ChannelReader<T> source, Channel<T> target, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> source

The source channel.

System.Threading.Channels.Channel<T> target

The target channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader of the target.

Type Parameters
Name Description
T

The type contained by the source channel and written to the target..

| Improve this Doc View Source

PipeTo<T>(ChannelReader<T>, ChannelWriter<T>, Boolean, CancellationToken)

Reads all entries from the source channel and writes them to the target. This is useful for managing different buffers sizes, especially if the source reader comes from a .Transform function.

Declaration
public static ValueTask<long> PipeTo<T>(this ChannelReader<T> source, ChannelWriter<T> target, bool complete, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> source

The source channel.

System.Threading.Channels.ChannelWriter<T> target

The target channel.

System.Boolean complete

Indicates to call complete on the target when the source is complete.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The type contained by the source channel and written to the target..

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, Action<T, Int64>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, Action<T, long> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Action<T, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writreadinging.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, Action<T, Int64>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, Action<T, long> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Action<T, System.Int64> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writreadinging.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, Action<T>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, Action<T> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Action<T> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, Action<T>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, Action<T> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Action<T> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, CancellationToken, Action<T, Int64>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Action<T, long> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<T, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writreadinging.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<T>(ChannelReader<T>, CancellationToken, Action<T>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Action<T> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<T> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, Action<TRead, Int64>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, Action<TRead, long> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Action<TRead, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, Action<TRead, Int64>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, Action<TRead, long> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Action<TRead, System.Int64> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

The optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, Action<TRead>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, Action<TRead> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Action<TRead> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, Action<TRead>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, Action<TRead> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Action<TRead> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

The optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Action<TRead, Int64>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Action<TRead, long> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The optional cancellation token.

System.Action<TRead, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAll<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Action<TRead>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAll<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Action<TRead> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The optional cancellation token.

System.Action<TRead> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsLines(ChannelReader<String>, TextWriter, Boolean, CancellationToken)

Reads items from the channel and writes to the target writer.

Declaration
public static ValueTask<long> ReadAllAsLines(this ChannelReader<string> reader, TextWriter receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.String> reader

The channel reader to read from.

System.IO.TextWriter receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

| Improve this Doc View Source

ReadAllAsLines(ChannelReader<String>, TextWriter, CancellationToken, Boolean)

Reads items from the channel and writes to the target writer.

Declaration
public static ValueTask<long> ReadAllAsLines(this ChannelReader<string> reader, TextWriter receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<System.String> reader

The channel reader to read from.

System.IO.TextWriter receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

| Improve this Doc View Source

ReadAllAsLines<T>(Channel<T, String>, TextWriter, Boolean, CancellationToken)

Reads items from the channel and writes to the target writer.

Declaration
public static ValueTask<long> ReadAllAsLines<T>(this Channel<T, string> channel, TextWriter receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<T, System.String> channel

The channel to read from.

System.IO.TextWriter receiver

The TextWriter to recieve the lines.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsLines<T>(Channel<T, String>, TextWriter, CancellationToken, Boolean)

Reads items from the channel and writes to the target writer.

Declaration
public static ValueTask<long> ReadAllAsLines<T>(this Channel<T, string> channel, TextWriter receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<T, System.String> channel

The channel to read from.

System.IO.TextWriter receiver

The TextWriter to recieve the lines.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, Func<T, Int64, ValueTask>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, Func<T, long, ValueTask> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, Func<T, Int64, ValueTask>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, Func<T, long, ValueTask> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, Func<T, ValueTask>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, Func<T, ValueTask> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, Func<T, ValueTask>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, Func<T, ValueTask> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, CancellationToken, Func<T, Int64, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Func<T, long, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<T>(ChannelReader<T>, CancellationToken, Func<T, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Func<T, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Int64, ValueTask>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, long, ValueTask> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Int64, ValueTask>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, long, ValueTask> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, ValueTask>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, ValueTask> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, ValueTask>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, ValueTask> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, Int64, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, long, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllConcurrently<T>(ChannelReader<T>, Int32, Action<T>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrently<T>(this ChannelReader<T> reader, int maxConcurrency, Action<T> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Action<T> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllConcurrently<T>(ChannelReader<T>, Int32, CancellationToken, Action<T>)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrently<T>(this ChannelReader<T> reader, int maxConcurrency, CancellationToken cancellationToken, Action<T> receiver)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<T> receiver

The receiver function.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllConcurrently<TWrite, TRead>(Channel<TWrite, TRead>, Int32, Action<TRead>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrently<TWrite, TRead>(this Channel<TWrite, TRead> channel, int maxConcurrency, Action<TRead> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Action<TRead> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllConcurrently<TWrite, TRead>(Channel<TWrite, TRead>, Int32, CancellationToken, Action<TRead>)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrently<TWrite, TRead>(this Channel<TWrite, TRead> channel, int maxConcurrency, CancellationToken cancellationToken, Action<TRead> receiver)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<TRead> receiver

The receiver function.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllConcurrentlyAsync<T>(ChannelReader<T>, Int32, Func<T, ValueTask>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrentlyAsync<T>(this ChannelReader<T> reader, int maxConcurrency, Func<T, ValueTask> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllConcurrentlyAsync<T>(ChannelReader<T>, Int32, CancellationToken, Func<T, ValueTask>)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrentlyAsync<T>(this ChannelReader<T> reader, int maxConcurrency, CancellationToken cancellationToken, Func<T, ValueTask> receiver)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadAllConcurrentlyAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, Func<TRead, ValueTask>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, int maxConcurrency, Func<TRead, ValueTask> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAllConcurrentlyAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, CancellationToken, Func<TRead, ValueTask>)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> ReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, int maxConcurrency, CancellationToken cancellationToken, Func<TRead, ValueTask> receiver)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadAvailable<T>(ChannelReader<T>)

Creates an enumerable that will read from the channel until no more are available for read.

Declaration
public static IEnumerable<T> ReadAvailable<T>(this ChannelReader<T> reader)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

An enumerable that will read from the channel until no more are available for read

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadBatchAsync<T>(ChannelReader<T>, Int32, CancellationToken)

Reads from the channel up to the max count.

Declaration
public static ValueTask<List<T>> ReadBatchAsync<T>(this ChannelReader<T> reader, int max, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 max

The max size of the batch.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Collections.Generic.List<T>>

The batch requested.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadUntilCancelled<T>(ChannelReader<T>, CancellationToken, Action<T, Int64>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelled<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Action<T, long> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<T, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadUntilCancelled<T>(ChannelReader<T>, CancellationToken, Action<T>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelled<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Action<T> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<T> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadUntilCancelled<TWrite, TRead>(Channel<TWrite, TRead>, Action<TRead>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelled<TWrite, TRead>(this Channel<TWrite, TRead> channel, Action<TRead> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Action<TRead> receiver

The receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadUntilCancelled<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Action<TRead, Int64>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelled<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Action<TRead, long> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Action<TRead, System.Int64> receiver

The receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadUntilCancelledAsync<T>(ChannelReader<T>, CancellationToken, Func<T, Int64, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelledAsync<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Func<T, long, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadUntilCancelledAsync<T>(ChannelReader<T>, CancellationToken, Func<T, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelledAsync<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Func<T, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

ReadUntilCancelledAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, Int64, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelledAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, long, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Int64, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ReadUntilCancelledAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, ValueTask>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> ReadUntilCancelledAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, ValueTask> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Threading.Tasks.ValueTask> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

Source<T>(Channel<String, T>, TextReader, Boolean, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<T> Source<T>(this Channel<string, T> target, TextReader source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<System.String, T> target

The channel to write to.

System.IO.TextReader source

The source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader.

Type Parameters
Name Description
T

The output type of the channel.

| Improve this Doc View Source

Source<T>(Channel<String, T>, TextReader, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<T> Source<T>(this Channel<string, T> target, TextReader source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<System.String, T> target

The channel to write to.

System.IO.TextReader source

The source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader.

Type Parameters
Name Description
T

The output type of the channel.

| Improve this Doc View Source

Source<TWrite, TRead>(Channel<TWrite, TRead>, IAsyncEnumerable<TWrite>, Boolean, CancellationToken)

Executes all entries from the source and passes their result to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> Source<TWrite, TRead>(this Channel<TWrite, TRead> target, IAsyncEnumerable<TWrite> source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IAsyncEnumerable<TWrite> source

The asynchronous source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

Source<TWrite, TRead>(Channel<TWrite, TRead>, IAsyncEnumerable<TWrite>, CancellationToken)

Executes all entries from the source and passes their result to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> Source<TWrite, TRead>(this Channel<TWrite, TRead> target, IAsyncEnumerable<TWrite> source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IAsyncEnumerable<TWrite> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

Source<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<TWrite>, Boolean, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> Source<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<TWrite> source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<TWrite> source

The source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

Source<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<TWrite>, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> Source<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<TWrite> source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<TWrite> source

The source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<Func<TWrite>>, Boolean, CancellationToken)

Executes all entries from the source and passes their result to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<Func<TWrite>> source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Func<TWrite>> source

The asynchronous source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<Func<TWrite>>, CancellationToken)

Executes all entries from the source and passes their result to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<Func<TWrite>> source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Func<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<Task<TWrite>>, Boolean, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<Task<TWrite>> source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<TWrite>> source

The asynchronous source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<Task<TWrite>>, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<Task<TWrite>> source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<ValueTask<TWrite>>, Boolean, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<ValueTask<TWrite>> source, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<TWrite>> source

The asynchronous source data to use.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, IEnumerable<ValueTask<TWrite>>, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, IEnumerable<ValueTask<TWrite>> source, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, IEnumerable<Func<TWrite>>, CancellationToken)

Executes all entries from the source and passes their result to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, int maxConcurrency, IEnumerable<Func<TWrite>> source, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Func<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, IEnumerable<Task<TWrite>>, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, int maxConcurrency, IEnumerable<Task<TWrite>> source, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

SourceAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, IEnumerable<ValueTask<TWrite>>, CancellationToken)

Writes all entries from the source to the channel. Calls complete when finished.

Declaration
public static ChannelReader<TRead> SourceAsync<TWrite, TRead>(this Channel<TWrite, TRead> target, int maxConcurrency, IEnumerable<ValueTask<TWrite>> source, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<TWrite>> source

The asynchronous source data to use.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TRead>

The channel reader.

Type Parameters
Name Description
TWrite

The input type of the channel.

TRead

The output type of the channel.

| Improve this Doc View Source

TaskPipeAsync<TIn, TOut>(ChannelReader<TIn>, Func<TIn, Task<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> TaskPipeAsync<TIn, TOut>(this ChannelReader<TIn> source, Func<TIn, Task<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Func<TIn, System.Threading.Tasks.Task<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

TaskPipeAsync<TIn, TOut>(ChannelReader<TIn>, Int32, Func<TIn, Task<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> TaskPipeAsync<TIn, TOut>(this ChannelReader<TIn> source, int maxConcurrency, Func<TIn, Task<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<TIn> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TIn, System.Threading.Tasks.Task<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TIn

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

TaskPipeAsync<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Func<TRead, Task<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> TaskPipeAsync<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, Func<TRead, Task<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Func<TRead, System.Threading.Tasks.Task<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

TaskPipeAsync<TWrite, TRead, TOut>(Channel<TWrite, TRead>, Int32, Func<TRead, Task<TOut>>, Int32, Boolean, CancellationToken)

Reads all entries and applies the values to the provided transform function before buffering the results into another channel for consumption.

Declaration
public static ChannelReader<TOut> TaskPipeAsync<TWrite, TRead, TOut>(this Channel<TWrite, TRead> source, int maxConcurrency, Func<TRead, Task<TOut>> transform, int capacity = -1, bool singleReader = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TRead, System.Threading.Tasks.Task<TOut>> transform

The transform function to apply the source entries before passing on to the output.

System.Int32 capacity

The width of the pipe: how many entries to buffer while waiting to be read from.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<TOut>

The channel reader containing the output.

Type Parameters
Name Description
TWrite

The type being accepted by the channel.

TRead

The type contained by the source channel.

TOut

The outgoing type from the resultant channel.

| Improve this Doc View Source

TaskReadAllAsync<T>(ChannelReader<T>, Func<T, Task>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader, Func<T, Task> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

TaskReadAllAsync<T>(ChannelReader<T>, Func<T, Task>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader, Func<T, Task> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Func<T, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

TaskReadAllAsync<T>(ChannelReader<T>, CancellationToken, Func<T, Task>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<T>(this ChannelReader<T> reader, CancellationToken cancellationToken, Func<T, Task> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<T, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Int64, Task>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, long, Task> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Int64, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Int64, Task>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, long, Task> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Int64, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Task>, Boolean, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, Task> receiver, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, Func<TRead, Task>, CancellationToken, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, Func<TRead, Task> receiver, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Func<TRead, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, Int64, Task>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, long, Task> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

System.Func<TRead, System.Int64, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllAsync<TWrite, TRead>(Channel<TWrite, TRead>, CancellationToken, Func<TRead, Task>, Boolean)

Reads items from the channel and passes them to the receiver.

Declaration
public static ValueTask<long> TaskReadAllAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, CancellationToken cancellationToken, Func<TRead, Task> receiver, bool deferredExecution = false)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Func<TRead, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Boolean deferredExecution

If true, calls await Task.Yield() before reading.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

The count of items read after the reader has completed. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

TaskReadAllConcurrentlyAsync<T>(ChannelReader<T>, Int32, Func<T, Task>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> TaskReadAllConcurrentlyAsync<T>(this ChannelReader<T> reader, int maxConcurrency, Func<T, Task> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<T, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

TaskReadAllConcurrentlyAsync<TWrite, TRead>(Channel<TWrite, TRead>, Int32, Func<TRead, Task>, CancellationToken)

Reads items from the channel and passes them to the receiver.

Declaration
public static Task<long> TaskReadAllConcurrentlyAsync<TWrite, TRead>(this Channel<TWrite, TRead> channel, int maxConcurrency, Func<TRead, Task> receiver, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> channel

The channel to read from.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Func<TRead, System.Threading.Tasks.Task> receiver

The async receiver function.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task that completes when no more reading is to be done.

Type Parameters
Name Description
TWrite

The item type of the writer.

TRead

The item type of the reader.

| Improve this Doc View Source

ToChannel(TextReader, Int32, Boolean, Boolean, CancellationToken)

Writes all lines from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<string> ToChannel(this TextReader source, int capacity = -1, bool singleReader = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.IO.TextReader source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<System.String>

The channel reader containing the results.

| Improve this Doc View Source

ToChannel(TextReader, Int32, Boolean, CancellationToken, Boolean)

Writes all lines from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<string> ToChannel(this TextReader source, int capacity, bool singleReader, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.IO.TextReader source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

Returns
Type Description
System.Threading.Channels.ChannelReader<System.String>

The channel reader containing the results.

| Improve this Doc View Source

ToChannel<T>(IAsyncEnumerable<T>, Int32, Boolean, Boolean, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IAsyncEnumerable<T> source, int capacity = -1, bool singleReader = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<T> source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannel<T>(IAsyncEnumerable<T>, Int32, Boolean, CancellationToken, Boolean)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IAsyncEnumerable<T> source, int capacity, bool singleReader, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<T> source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannel<T>(IAsyncEnumerable<T>, ChannelOptions, Boolean, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IAsyncEnumerable<T> source, ChannelOptions channelOptions, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IAsyncEnumerable<T> source

The source data to use.

System.Threading.Channels.ChannelOptions channelOptions

The options for configuring the new channel.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannel<T>(IEnumerable<T>, Int32, Boolean, Boolean, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IEnumerable<T> source, int capacity = -1, bool singleReader = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannel<T>(IEnumerable<T>, Int32, Boolean, CancellationToken, Boolean)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IEnumerable<T> source, int capacity, bool singleReader, CancellationToken cancellationToken, bool deferredExecution = false)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

The source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Threading.CancellationToken cancellationToken

The cancellation token.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannel<T>(IEnumerable<T>, ChannelOptions, Boolean, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannel<T>(this IEnumerable<T> source, ChannelOptions channelOptions, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

The source data to use.

System.Threading.Channels.ChannelOptions channelOptions

The options for configuring the new channel.

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing to the channel.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<Func<T>>, Int32, Boolean, Int32, CancellationToken)

Asynchronously executes all entries and writes their results to a channel.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<Func<T>> source, int capacity = -1, bool singleReader = false, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Func<T>> source

The asynchronous source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<Func<T>>, ChannelOptions, Int32, CancellationToken)

Asynchronously executes all entries and writes their results to a channel.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<Func<T>> source, ChannelOptions channelOptions, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Func<T>> source

The asynchronous source data to use.

System.Threading.Channels.ChannelOptions channelOptions

The options for configuring the new channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<Task<T>>, Int32, Boolean, Int32, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<Task<T>> source, int capacity = -1, bool singleReader = false, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> source

The asynchronous source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<Task<T>>, ChannelOptions, Int32, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<Task<T>> source, ChannelOptions channelOptions, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> source

The asynchronous source data to use.

System.Threading.Channels.ChannelOptions channelOptions

The options for configuring the new channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<ValueTask<T>>, Int32, Boolean, Int32, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<ValueTask<T>> source, int capacity = -1, bool singleReader = false, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<T>> source

The asynchronous source data to use.

System.Int32 capacity

The optional bounded capacity of the channel. Default is unbound.

System.Boolean singleReader

True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToChannelAsync<T>(IEnumerable<ValueTask<T>>, ChannelOptions, Int32, CancellationToken)

Writes all entries from the source to a channel and calls complete when finished.

Declaration
public static ChannelReader<T> ToChannelAsync<T>(this IEnumerable<ValueTask<T>> source, ChannelOptions channelOptions, int maxConcurrency = 1, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<T>> source

The asynchronous source data to use.

System.Threading.Channels.ChannelOptions channelOptions

The options for configuring the new channel.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Channels.ChannelReader<T>

The channel reader containing the results.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

ToListAsync<T>(ChannelReader<T>)

Adds all items in the reader to a list and returns when the channel completes. Note: this should only be used when the results of the channel are guaranteed to be limited.

Declaration
public static ValueTask<List<T>> ToListAsync<T>(this ChannelReader<T> reader)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> reader

The channel reader to read from.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Collections.Generic.List<T>>

A list containing all the items from the completed channel.

Type Parameters
Name Description
T

The item type.

| Improve this Doc View Source

Transform<T, TResult>(Channel<T>, Func<T, TResult>)

Transforms the

Declaration
public static TransformChannel<T, TResult> Transform<T, TResult>(this Channel<T> source, Func<T, TResult> transform)
Parameters
Type Name Description
System.Threading.Channels.Channel<T> source

The source channel reader.

System.Func<T, TResult> transform

The transform function.

Returns
Type Description
TransformChannel<T, TResult>

A channel reader representing the tranformed results.

Type Parameters
Name Description
T

Specifies the type of data that may be written to the channel.

TResult

Specifies the type of data that may be read from the channel.

| Improve this Doc View Source

Transform<T, TResult>(ChannelReader<T>, Func<T, TResult>)

Transforms the

Declaration
public static ChannelReader<TResult> Transform<T, TResult>(this ChannelReader<T> source, Func<T, TResult> transform)
Parameters
Type Name Description
System.Threading.Channels.ChannelReader<T> source

The source channel reader.

System.Func<T, TResult> transform

The transform function.

Returns
Type Description
System.Threading.Channels.ChannelReader<TResult>

A channel reader representing the tranformed results.

Type Parameters
Name Description
T

The output type of the provided source reader and input type of the transform.

TResult

The output type of the transform.

| Improve this Doc View Source

Transform<TWrite, TRead, TResult>(Channel<TWrite, TRead>, Func<TRead, TResult>)

Transforms the

Declaration
public static TransformChannel<TWrite, TRead, TResult> Transform<TWrite, TRead, TResult>(this Channel<TWrite, TRead> source, Func<TRead, TResult> transform)
Parameters
Type Name Description
System.Threading.Channels.Channel<TWrite, TRead> source

The source channel reader.

System.Func<TRead, TResult> transform

The transform function.

Returns
Type Description
TransformChannel<TWrite, TRead, TResult>

A channel reader representing the tranformed results.

Type Parameters
Name Description
TWrite

Specifies the type of data that may be written to the channel.

TRead

Specifies the type of data read from the source channel.

TResult

Specifies the type of data that may be read from the channel.

| Improve this Doc View Source

WaitToWriteAndThrowIfClosedAsync<T>(ChannelWriter<T>, Boolean, CancellationToken)

Waits for opportunity to write to a channel and throws a ChannelClosedException if the channel is closed.

Declaration
public static ValueTask WaitToWriteAndThrowIfClosedAsync<T>(this ChannelWriter<T> writer, bool deferredExecution, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> writer

The channel writer.

System.Boolean deferredExecution

If true, calls await Task.Yield() before continuing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
T

The type being written to the channel

| Improve this Doc View Source

WaitToWriteAndThrowIfClosedAsync<T>(ChannelWriter<T>, String, Boolean, CancellationToken)

Waits for opportunity to write to a channel and throws a ChannelClosedException if the channel is closed.

Declaration
public static ValueTask WaitToWriteAndThrowIfClosedAsync<T>(this ChannelWriter<T> writer, string ifClosedMessage, bool deferredExecution, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> writer

The channel writer.

System.String ifClosedMessage

The message to include with the ChannelClosedException if thrown.

System.Boolean deferredExecution

If true, calls await Task.Yield() before continuing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
T

The type being written to the channel

| Improve this Doc View Source

WaitToWriteAndThrowIfClosedAsync<T>(ChannelWriter<T>, String, CancellationToken)

Waits for opportunity to write to a channel and throws a ChannelClosedException if the channel is closed.

Declaration
public static ValueTask WaitToWriteAndThrowIfClosedAsync<T>(this ChannelWriter<T> writer, string ifClosedMessage = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> writer

The channel writer.

System.String ifClosedMessage

The message to include with the ChannelClosedException if thrown.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
T

The type being written to the channel

| Improve this Doc View Source

WaitToWriteAndThrowIfClosedAsync<T>(ChannelWriter<T>, CancellationToken)

Waits for opportunity to write to a channel and throws a ChannelClosedException if the channel is closed.

Declaration
public static ValueTask WaitToWriteAndThrowIfClosedAsync<T>(this ChannelWriter<T> writer, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> writer

The channel writer.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask
Type Parameters
Name Description
T

The type being written to the channel

| Improve this Doc View Source

WriteAll<T>(ChannelWriter<T>, IEnumerable<T>, Boolean, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target, IEnumerable<T> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<T> source

The source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAll<T>(ChannelWriter<T>, IEnumerable<T>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAll<T>(this ChannelWriter<T> target, IEnumerable<T> source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<T> source

The source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IAsyncEnumerable<T>, Boolean, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IAsyncEnumerable<T> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IAsyncEnumerable<T> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IAsyncEnumerable<T>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IAsyncEnumerable<T> source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IAsyncEnumerable<T> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<Func<T>>, Boolean, Boolean, CancellationToken)

Asynchronously executes all entries and writes their results to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<Func<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Func<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<Func<T>>, Boolean, CancellationToken)

Asynchronously executes all entries and writes their results to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<Func<T>> source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Func<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<Task<T>>, Boolean, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<Task<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<Task<T>>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<Task<T>> source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<ValueTask<T>>, Boolean, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<ValueTask<T>> source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllAsync<T>(ChannelWriter<T>, IEnumerable<ValueTask<T>>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static ValueTask<long> WriteAllAsync<T>(this ChannelWriter<T> target, IEnumerable<ValueTask<T>> source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllConcurrentlyAsync<T>(ChannelWriter<T>, Int32, IEnumerable<Func<T>>, Boolean, CancellationToken)

Asynchronously executes all entries and writes their results to the channel.

Declaration
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target, int maxConcurrency, IEnumerable<Func<T>> source, bool complete = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Func<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllConcurrentlyAsync<T>(ChannelWriter<T>, Int32, IEnumerable<Task<T>>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target, int maxConcurrency, IEnumerable<Task<T>> source, bool complete = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllConcurrentlyAsync<T>(ChannelWriter<T>, Int32, IEnumerable<ValueTask<T>>, Boolean, CancellationToken)

Asynchronously writes all entries from the source to the channel.

Declaration
public static Task<long> WriteAllConcurrentlyAsync<T>(this ChannelWriter<T> target, int maxConcurrency, IEnumerable<ValueTask<T>> source, bool complete = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<T> target

The channel to write to.

System.Int32 maxConcurrency

The maximum number of concurrent operations. Greater than 1 may likely cause results to be out of order.

System.Collections.Generic.IEnumerable<System.Threading.Tasks.ValueTask<T>> source

The asynchronous source data to use.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

Type Parameters
Name Description
T

The input type of the channel.

| Improve this Doc View Source

WriteAllLines(ChannelWriter<String>, TextReader, Boolean, Boolean, CancellationToken)

Consumes all lines from a TextReader and writes them to a channel.

Declaration
public static ValueTask<long> WriteAllLines(this ChannelWriter<string> target, TextReader source, bool complete = false, bool deferredExecution = false, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<System.String> target

The channel to write to.

System.IO.TextReader source

The text reader to consume from.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Boolean deferredExecution

If true, calls await Task.Yield() before writing.

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

| Improve this Doc View Source

WriteAllLines(ChannelWriter<String>, TextReader, Boolean, CancellationToken)

Consumes all lines from a TextReader and writes them to a channel.

Declaration
public static ValueTask<long> WriteAllLines(this ChannelWriter<string> target, TextReader source, bool complete, CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.Channels.ChannelWriter<System.String> target

The channel to write to.

System.IO.TextReader source

The text reader to consume from.

System.Boolean complete

If true, will call .Complete() if all the results have successfully been written (or the source is emtpy).

System.Threading.CancellationToken cancellationToken

An optional cancellation token.

Returns
Type Description
System.Threading.Tasks.ValueTask<System.Int64>

A task containing the count of items written that completes when all the data has been written to the channel writer. The count should be ignored if the number of iterations could exceed the max value of long.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX