C# – Using Channel as an async queue

The Channel class (from System.Threading.Channels) is a non-blocking async queue. It implements the producer-consumer pattern, which has two parts: Compare this with using BlockingCollection, which is a blocking concurrent queue. In this article, I’ll show how to use a Channel. 1 – Create the Channel The first step is to create the Channel object. Here’s … Read more

C# – Example of using BlockingCollection

The BlockingCollection class is a blocking concurrent queue. It provides an implementation of the producer-consumer pattern. There are two parts to this pattern: BlockingCollection is thread-safe, which means it’s designed to be used by many threads at once. Here’s an example of using BlockingCollection with one consumer and two producers: Note: BlockingCollection.IsCompleted means the queue … Read more