8000 GitHub - wandysaputra/BlockingCollection
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wandysaputra/BlockingCollection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blocking Collection

ConcurrentQueue ConcurrentStack ConcurrentBag
Order First-in-First-out Last-in-First-out Order is unspecified
Based on performance.
Effecient if same threads are adding and removing.
Add Item Enqueue() Push() Add()
Remove Item TryDequeue() TryPop() TryTake()

To avoing polling we can use BlockingCollection

Multiple threads or tasks can add items to the collection concurrently, and if the collection reaches its specified maximum capacity, the producing threads will block until an item is removed. Multiple consumers can remove items concurrently, and if the collection becomes empty, the consuming threads will block until a producer adds an item. A producing thread can call CompleteAdding to indicate that no more items will be added. Consumers monitor the IsCompleted property to know when the collection is empty and no more items will be added.

GetConsumingEnumerable

BlockingCollection<T> provides a GetConsumingEnumerable method that enables consumers to use foreach (For Each in Visual Basic) to remove items until the collection is completed, which means it is empty and no more items will be added.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0