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 8917653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:32:39+00:00 2026-06-15T05:32:39+00:00

I have a heavily threaded application with a ReadOnlyCollection as follows: internal static ReadOnlyCollection<DistributorBackpressure44>

  • 0

I have a heavily threaded application with a ReadOnlyCollection as follows:

internal static ReadOnlyCollection<DistributorBackpressure44> DistributorBackpressure44Cache
{
    get
    {
        return _distributorBackpressure44;
    }
    set
    {
        _distributorBackpressure44 = value;
    }
}

I have one place in the app where this collection is replaced (always on a separate thread) and it looks like this:

    CicApplication.DistributorBackpressure44Cache = new ReadOnlyCollection<DistributorBackpressure44>(someQueryResults.ToList());

I have many places in the code where this collection is accessed, usually via Linq queries, in many different threads. The code often looks something like this:

foreach (DistributorBackpressure44 distributorBackpressure44 in CicApplication.DistributorBackpressure44Cache.Where(row => row.Coater == coater && row.CoaterTime >= targetTime).ToList())
{
 ...
 ...
}

I assume what I’m doing is thread-safe, without the need to do any locking? What I’m not sure about is what happens with the query above if it occurs at the exact same time the collection is getting replaced in a different thread?

  • 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-15T05:32:40+00:00Added an answer on June 15, 2026 at 5:32 am

    Reference assignments are atomic, so yes, it is thread safe. But only as long as you don’t rely on the data to be ready to be read exactly the moment after it is written. This is because of caching, you might want to throw in a volatile to prevent that.

    See also reference assignment is atomic so why is Interlocked.Exchange(ref Object, Object) needed?.

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

Sidebar

Related Questions

I currently have heavily multi-threaded server application, and I'm shopping around for a good
We have an existing application that relies heavily on stored procedures and untyped DataSets.
I have written a PHP application that uses Objects heavily. Added, deleting, updating etc..
I am facing numerous crashes on a application which is heavily multi-threaded. Reading these
I have a multi-threaded Delphi 6 Pro application that I am currently working on
I have an application using TTS very heavily. It's working fine, but I need
I have an C++ application (heavily shortened down, shown below); #include <iostream> #include MyClass.h
I have a Java application whose UI relies heavily on audio. On Windows and
I have a web application the relies heavily on web services. Everything with the
I have application which heavily use log4j out of the box. This uses lots

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.