System.Threading.Channels by Microsoft

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

 ChannelWriter<T>

public abstract class ChannelWriter<T>
Provides a base class for writing to a channel.
protected ChannelWriter()

Initializes an instance of the ChannelWriter<T> class.

public void Complete(Exception error = null)

Mark the channel as being complete, meaning no more items will be written to it.

public virtual bool TryComplete(Exception error = null)

Attempts to mark the channel as being completed, meaning no more data will be written to it.

public abstract bool TryWrite(T item)

Attempts to write the specified item to the channel.

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

Returns a ValueTask<T> that will complete when space is available to write an item.

public virtual ValueTask WriteAsync(T item, CancellationToken cancellationToken = default)

Asynchronously writes an item to the channel.