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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:58:27+00:00 2026-05-25T13:58:27+00:00

I downloaded Parallel Extensions for .NET 3.5 SP1 on DevLabs a while ago and

  • 0

I downloaded Parallel Extensions for .NET 3.5 SP1 on DevLabs a while ago and started using it. Everything seemed to work fine until I noticed some exceptions in the logs which I have a hard time to understand why they happened.

Here’s a snippet of the parallel task:

Parallel.ForEach(myJobArray, currentJob =>
{
    JobElements myJobElements = GetJobElements(currentJob);

    Parallel.For(0, myJobElements.Length, (currentIndex, loopState) =>
    {
        if (MyFunction(param1, myJobElements[currentIndex]))
        {
            loopState.Stop();
        }
    }
    );
}
);

Here’s the pseudo code of MyFunction:

private bool MyFunction(MyObject1 param1, MyObject2 param2)
{
    log(string.Format("start SubFunction1() from thread {0}", Thread.CurrentThread.ManagedThreadId));
    SubFunction1(); //which uses System.Diagnostics.Process to start a batch file (.bat) to execute a Perl script. If successful, a file will be generated.
    log(string.Format("end SubFunction1() from thread {0}", Thread.CurrentThread.ManagedThreadId));

    log(string.Format("start SubFunction2() from thread {0}", Thread.CurrentThread.ManagedThreadId));
    SubFunction2(); //which again, uses System.Diagnostics.Process to start another batch file (.bat) to execute a Perl script which transforms the file from step #1 to a new file.
    log(string.Format("end SubFunction2() from thread {0}", Thread.CurrentThread.ManagedThreadId));

}

The logs showed that one thread started SubFunction1() but never finished; i.e., there was no log entry saying something like “end SubFunction1()” with the same thread ID. Actually, the same thread seemed to move on to the next job in the array and call SubFunction1() again. The exception happened when another thread tried to stand in for the previous thread to start SubFunction2() and couldn’t find the file generated from SubFunction1().

I thought each thread was guaranteed to finish its tasks from start to finish and I can’t figure out why the logs show this way. I should also add that the behavior is not consistent; i.e., most of the time the program runs with no exceptions but sometimes it throws exceptions due to the aforemention problems.

Any thoughts?

  • 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-25T13:58:28+00:00Added an answer on May 25, 2026 at 1:58 pm

    I thought each thread was guaranteed to finish its tasks from start to finish and I can’t figure out why the logs show this way.

    This will not happen if SubFunction1() throws an exception.

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

Sidebar

Related Questions

I just downloaded the stable release of Reactive Extensions for .NET and am looking
I downloaded Reflector.Net and it's an .Exe outside VS. I remember (last year) when
I have downloaded the last samples of the Parallel Programming team, and I don't
I followed a tutorial from Utube on how to run parallel aplications using MPJ
I am using a C# implementation of Mersenne Twister I downloaded from CenterSpace .
I am working on a application which downloads using 1) Parallel.ForEach(linklist, x => DownloadAsync(x));
I'm using parallel linq, and I'm trying to download many urls concurrently using essentily
Also, I know css and image files can be downloaded in parallel. But can
This code works fine : Parallel.ForEach(photos, item => { WebClient webClient = new WebClient();
Since Microsoft probably killed all download links to the Parallel Extensions CTP, I am

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.