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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:33:21+00:00 2026-06-12T18:33:21+00:00

It seems like I am getting threading errors as a result of an inconsistent

  • 0

It seems like I am getting threading errors as a result of an inconsistent state of my IEnumerable. Specifically, List<T>.

Here’s my workflow:

List<string> IDs = getIDs();
RunTask(IDs);
RunTask(IDs);

public void RunTask(List<string> IDs)
{
    TaskScheduler scheduler = new TaskScheduler();
    TaskFactory factory = new TaskFactory(scheduler);
    var tasks = IDs.Select(name => factory.StartNew(() => action(name))).ToArray();
    Task.WaitAll(tasks);
}

I am getting a generic error on my WaitAll() call.

My thinking is that I am getting some sort of unsynchronized IEnumerator, and that I need to make a copy of my List via Array.CopyTo(), then pass it into my multiple threads.

This is my exception:

Error: One or more errors occurred.
One or more errors occurred.
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks)

Any thoughts on this matter?

  • 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-12T18:33:23+00:00Added an answer on June 12, 2026 at 6:33 pm

    I don’t think this is a threading error – it should be safe as long as each task does not modify the IDs list. Task.WaitAll() throws an AggregateException if any of the waited tasks throw an exception or are cancelled.

    You can access the InnerExceptions on the exception to see what the error(s) are.

    try
    {
        Task.WaitAll(tasks);
    }
    catch(AggregateException ex)
    {
        foreach(Exception in ex.InnerExceptions) { ... }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error with HG (Mercurial), it seems like it's having a
I am using eclipse 3.4.1 Java EE under Vista. It seems to like getting
This seems like it should be so easy but I am not getting an
I'm having a hard time getting my head around what seems like an obvious
I've been having no end of trouble just getting started with C++. Seems like
I'm having trouble getting HTML::Template 's <TMPL_IF> blocks to function -- it seems like
I am just getting started with MVC, and it seems like it will be
I was using BloomFilter in guava v.11.0.1 and it seems like I am getting
Seems like a lot of people have problems getting oAuth to work with Photobucket
Edit It seems like I am getting different responses on how the game actual

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.