Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / programming / threads

Simple Blocking Queue for Thread Communication and Inter-thread Invocation

4.67/5 (5 votes)
24 Jan 2011CPOL 8.6K  
In .NET 4.0, you can use:New Concurrent.BlockingCollection(New Queue)This even has an option on the constructor to let you specify a maximum queue depth. If it reaches this depth, a call to Add will block until the consumer thread takes something out of the queue.
In .NET 4.0, you can use:

New Concurrent.BlockingCollection(New Queue)

This even has an option on the constructor to let you specify a maximum queue depth. If it reaches this depth, a call to Add will block until the consumer thread takes something out of the queue.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)