Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1958032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:57:41+00:00 2026-05-17T07:57:41+00:00

I have a bounded blocking queue in an application that was written several years

  • 0

I have a bounded blocking queue in an application that was written several years ago. Let’s just say that the implementation is less than stellar, but it’s worked. However, it has some performance problems. It looks like the .NET 4.0 BlockingCollection<T> is the right replacement, but I need to make sure that it is actually a queue. That is, is it guaranteed to be strictly FIFO if used in a single-producer, single-consumer fashion?

The documentation doesn’t specifically say. The BlockingCollection topic does say (in the Remarks):

BlockingCollection<T> is similar to a
traditional blocking queue data
structure, except that the underlying
data storage mechanism is abstracted
away as an IProducerConsumerCollection<T>.

But nothing specifically says that things will be removed in the same order they’re added.

Anybody know for sure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T07:57:42+00:00Added an answer on May 17, 2026 at 7:57 am

    Well, BlockingCollection<T> is really designed for parallel work, where you have multiple simulataneous “producers” and one consumer (using GetConsumingEnumerable()).

    In this situation, you have no way to guarantee insertion order, so the ordering constraints aren’t specified.

    That being said, BlockingCollection<T> works upon any IProducerConsumerCollection<T> (specified in the constructor). If you don’t provide one in the constructor, internally, it will use a ConcurrentQueue<T>. This causes it to be FIFO, since it will actually be (internally) a queue. So yes, by default, it will be “guaranteed to be strictly FIFO if used in a single-producer, single-consumer fashion”, at least in the current implementation. If you want to force this for future proofing (since the queue is an implementation detail), just construct it as:

    var blockingCollection = new BlockingCollection<MyClass>(new ConcurrentQueue<MyClass>());
    

    That will guarantee that it uses a queue now, and in the future (since the queue is an implementation detail).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an in memory bounded queue in which multiple threads queue objects. Normally
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How
Have had to write my first proper multithreaded coded recently, and realised just how
i have checkedlistbox which is bounded to a datasource as foloowing : chListBox.DataSource =
I have a problem with bounded nested wildcards in Java generics. Here's a common
Suppose we have an ItemsControl, which is bounded to a source. Is there any
I want to create a custom modelbinder which validates the bounded model. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.