BlockingCollection and IProducerConsumerCollection in C#

Hi Folks,
 
Here we are learning what is Producer-consumer problem in C#. 
 
BlockingCollection<T> is a thread-safe collection class that provides the following features:
  • An implementation of the Producer-Consumer pattern.
  • Concurrent adding and taking of items from multiple threads.
  • Optional maximum capacity.
  • Insertion and removal operations that block when collection is empty or full.
  • Insertion and removal "try" operations that do not block or that block up to a specified period of time.
  • Encapsulates any collection type that implements IProducerConsumerCollection<T>
  • Cancellation with cancellation tokens.
  • Two kinds of enumeration with foreach (For Each in Visual Basic):

       - Read-only enumeration.
       - Enumeration that removes items as they are enumerated. 
Read More about this, please refer this link.
Ebook Download
View all
Learn
View all