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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:17:04+00:00 2026-05-14T15:17:04+00:00

I am looking at Skeet’s AtomicEnumerable but I’m not sure how to integrate it

  • 0

I am looking at Skeet’s AtomicEnumerable but I’m not sure how to integrate it into my current IEnumerable exmaple below (http://msmvps.com/blogs/jon_skeet/archive/2009/10/23/iterating-atomically.aspx)

Basically I want to foreach my blahs type in a thread-safe way.

thanks

so .. foreach on multiple threads … giving correct order

Blahs b = new Blahs();

foreach (string s in b)
{ }

public sealed class Blahs :  IEnumerable<string>
{
    private readonly IList<string> _data = new List<string>() { "blah1", "blah2", "blah3" };

    public IEnumerator<string> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}
  • 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-14T15:17:04+00:00Added an answer on May 14, 2026 at 3:17 pm

    Do you mean you want each thread to see the same sequence, or that between all the threads, each item should be seen exactly once?

    Are you able to use .NET 4? If so, Parallel Extensions (e.g. Parallel.ForEach) is your friend – it’s likely to be much safer than anything I could come up with 🙂

    EDIT: If you want to just iterate over the list completely in each thread, and nothing is going to be modifying the list, it will be thread-safe already. If you do need to modify the list, then you should create a copy of the list and iterate over that instead.

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

Sidebar

Related Questions

I need a cheat sheet for Java and started looking around, but could not
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
We're using Jon Skeet's proto-csharp-port, and I'm running into some difficulties when mixing it
I am looking for a way to import a datatable from Access into an
looking for a bit of help with my jQuery, (i know its not the
I'm looking for an algorithm for which I do not have the VBA knowledge
I would like to hide the current page that the user is looking at
I am fairly new to LINQ. I am looking at this code, and not
Jon Skeet said that and String.Empty are equivalent due to string interning. In looking
I've been looking quite a bit at Mr. Skeet's blog on how to re-implement

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.