<PackageReference Include="System.Threading.Channels" Version="10.0.12" />

System.Threading.Channels.ChannelReader<T>

public abstract class ChannelReader<T>
Provides a base class for reading from a channel.
public virtual bool CanCount { get; }

Gets a value that indicates whether Count is available for use on this ChannelReader<T> instance.

public virtual bool CanPeek { get; }

Gets a value that indicates whether TryPeek is available for use on this ChannelReader<T> instance.

public virtual Task Completion { get; }

Gets a Task that completes when no more data will ever be available to be read from this channel.

public virtual int Count { get; }

Gets the current number of items available from this channel reader.

protected ChannelReader()

Initializes an instance of the ChannelReader<T> class.

public virtual IAsyncEnumerable<T> ReadAllAsync(CancellationToken cancellationToken = default)

Creates an IAsyncEnumerable<T> that enables reading all of the data from the channel.

public virtual ValueTask<T> ReadAsync(CancellationToken cancellationToken = default)

Asynchronously reads an item from the channel.

public virtual bool TryPeek(out T item)

Attempts to peek at an item from the channel.

public abstract bool TryRead(out T item)

Attempts to read an item from the channel.

public abstract ValueTask<bool> WaitToReadAsync(CancellationToken cancellationToken = default)

Returns a ValueTask<T> that will complete when data is available to read.