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

  • SEARCH
  • Home
  • 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 8031143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:59:45+00:00 2026-06-05T00:59:45+00:00

I have System.Collections.Generic.List _myList and many threads can read from it or add items

  • 0

I have System.Collections.Generic.List _myList and many threads can read from it or add items to it simultaneously. From what I’ve read I should using ‘BlockingCollection’ so this will work. I also read about ReaderWriterLockSlim and lock, but I don’t figure out how to use them instead of BlockingCollection, so my question is can I do the same with:

  1. ReaderWriterLockSlim
  2. lock

instead of using ‘BlockingCollection’. If YES, can you please provide simple example and what pros and cons of using BlockingCollection, ReaderWriterLockSlim, lock?

UPDATED
readers will be much more than writers!

  • 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-06-05T00:59:46+00:00Added an answer on June 5, 2026 at 12:59 am

    ReaderWriterLockSlim:

    • is optimized for use cases, when reads from resourse occur more frequently, than writes;
    • can work with any type of resources (not only collections), because it’s just a hybrid synchronization construct.

    lock:

    • is a general purpose, rather simple, hybrid synchronization construct without any optimizations; thus, can make performance worse;
    • is a C# wrapper around Monitor class;
    • can work with any type of resources;

    BlockingCollection:

    • is a specific type of collection (concrete type of resource), that oriented to solve ‘producer-consumer’ tasks;
    • supports timeouts and cancellation mechanism (via cancellation tokens), which makes easier integration into code, which uses TPL.

    I think, your choice is BlockingCollection (if you really have many readers and writers).

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

Sidebar

Related Questions

I have a system.collections.generic.list(of ListBox) I would like to use the collection classes built-in
I don't know why I have an IndexOutOfRangeException when I am clearing a System.Collections.Generic.List<T>
Ii have a web method that looks like this: [WebMethod] public int ImportData(System.Collections.Generic.List<Record> importRecords)
I have following code that populates a System.Collections.Generic.List I don't like it so I
I have a web service that looks like this [WebMethod] public int Import(System.Collections.Generic.List<Record> importRecords)
So I have created the following script: class spImageUpload() { private static System.Collections.Generic.List<string> keywords;
I have System.Collections.Generic.Dictionary<A, B> dict where A and B are classes, and an instance
I have this code (C#): using System.Collections.Generic; namespace ConsoleApplication1 { public struct Thing {
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;

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.