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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:54:02+00:00 2026-05-25T01:54:02+00:00

I have getting error Collection was modified; enumeration operation may not execute. at System.Collections.Queue.QueueEnumerator.MoveNext()

  • 0

I have getting error
Collection was modified; enumeration operation may not execute.
at System.Collections.Queue.QueueEnumerator.MoveNext()

        Queue ReqQ = (Application["ReqQ"] != null) ? ((Queue)Application["ReqQ"]) : 
new Queue(50);

             if (ReqQ != null)
             {
                      foreach (object OReq in ReqQ)
                    {
                             string mId = (string)OReq;
                             if (mId.Split('~')[1].Equals(reqUid.Split('~')[1]) && (DateTime.Parse(mId.Split('~')[0]).AddMinutes(1 * int.Parse(string.IsNullOrEmpty(delay) ? "0" : delay)) > DateTime.Now))

                             {
                                      isSuccess = false;
                                      break;
                            }
                     }

                }

                else
                {
                            ReqQ = new Queue(10);
                             isSuccess = true;
                }

                if (isSuccess)
                {

                         if (ReqQ.Count >= 10) //only keep last 10 messages in application cache
                                ReqQ.Dequeue();

                                    ReqQ.Enqueue(reqUid);
                                    Application["ReqQ"] = ReqQ; 
                } 
  • 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-25T01:54:03+00:00Added an answer on May 25, 2026 at 1:54 am

    It looks like you’ve got a single collection which you’re reading and modifying from multiple threads (for different requests). To start with that’s not safe using Queue – and it’s particularly not true if you’re iterating through the collection while you modify it in another. (EDIT: I’ve just noticed you’re not even using a generic collection. If you’re using .NET 4, there’s no reason to use the non-generic collections…)

    It’s unclear what you’re trying to achieve – you may be able to get away with just changing to use ConcurrentQueue<T> instead, but you need to be aware that by the time you’ve iterated over the collection, the values you read may already have been dequeued in another thread.

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

Sidebar

Related Questions

I have been getting an error in VB .Net object reference not set to
I am getting an error message expression must have constant value when initializing an
I keep getting this error all over the place where I only have jquery
I'm getting an error when I use the SharpZipLib. I have code that looks
I have zero idea as to why I'm getting this error.
I have done simple java app for blackberry, while building am getting following error.
I keep getting the following error message ERROR 1064 (42000): You have an error
I am getting JQUERY undefined error. Do you have any idea (code below). <%@
I have downloaded a web project from CodePlex and am getting the following error
I am getting a strange error using jQuery 1.3.2 and Firefox. I have created

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.