Questions tagged [system.threading.channels]

Provides a set of highly scalable, low/no-allocation synchronization data structures for passing data between producers and consumers asynchronously.


System.Threading.Channels contains the abstractions and base implementation for async friendly queues as a replacement for synchronous thread-safe BlockingCollection and ConcurrentQueue.

It's also a partial replacement for the System.Threading.Tasks.Dataflow async friendly queues (which is implicitly implemented inside BufferBlock and other blocks).

The API Proposal is probably the only official documentation at the moment.

Exploring System.Threading.Channels offers a good overview of channels

Decoupling

Publishers and subscribers can only access a channel through a ChannelWriter and ChannelReader respectively. This decouples publishers, subscribers and the channel implementation itself.

Backpressure

A Bounded Channel allows only a specific number of items. Its behaviour when full depends on the BoundedChannelFullMode option. By default, publishers will have to wait asynchronously if a channel becomes full.

Other values of the BoundedChannelFullMode enum allow different behaviours. For example, DropOldest can be used to create a circular buffer. DropWrite can be used to throttle publishers by rejecting overflowing messages.

65 questions
0
votes
1 answer

Contentious paralleled work between two collections of objects

I am trying to simulate work between two collections asynchronously and in parallel, I have a ConcurrentQueue of customers and a collection of workers. I need the workers to take a Customer from the queue perform work on the customer and once done…
0
votes
1 answer

In SignalR Core using ChannelWriter: Do I need to call TryComplete twice if there's an exception?

Here is an excerpt from the Use streaming in ASP.NET Core SignalR article by Microsoft: private async Task WriteItemsAsync( ChannelWriter writer, int count, int delay, CancellationToken cancellationToken) { try { …
0
votes
0 answers

Unable to play the sample client to server streaming example in asp .net core signalR

I am working on the .NET framework 4.6.1. I want to stream data from the typescript client to my service. I have taken code from here. This is the service side code : public async Task UploadStream(ChannelReader stream) …
0
votes
1 answer

AspNetCore SignalR Streaming Clarifications

I have been going through the recent signalr documentation, and i stumbled across the new feature called Streaming. I also, and i managed to get it running with a JS client. However, i am still not clear on when to use it. 1- Does ChannelReader…
-1
votes
1 answer

How to store a Channel in a Concurrent Dictionary

A rather tricky one here but the concept I'm trying to fathom is fairly simple. I have a public static concurrent dictionary, accessible from other classes and threads: public static readonly ConcurrentDictionary
OJB1
  • 2,245
  • 5
  • 31
  • 63
1 2 3 4
5