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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:27:54+00:00 2026-06-01T21:27:54+00:00

I have an application that are executing 4 different jobs parallel. I use the

  • 0

I have an application that are executing 4 different jobs parallel. I use the parallel task library.

The code looks like this:

while (true)
        {
            var fetch = new FetcherHandler();

            var tasks = new Task[4];

            tasks[0] = Task.Factory.StartNew(fetch.GetJobs);

            tasks[1] = Task.Factory.StartNew(fetch.GetStatusNew);

            tasks[2] = Task.Factory.StartNew(fetch.GetJobsForStatus);

            tasks[3] = Task.Factory.StartNew(fetch.GetStatusOld);
            Task.WaitAll(tasks);

            Thread.Sleep(10000);
        }

The thread.Sleep above will never be reached since all these 4 tasks is in a never ending loop. Code example for the first task:

public void GetJobs()
        {
    while (true)
            {
                try
                    {
                        handler.GetNewJob();
                        }
                    catch (Exception exception)
                    {
                            var mail = new MailService();
                            mail.SendExeption("Error has accured in GetJobs", exception);
                            throw;
                        }
                    }
                }
                Thread.Sleep(15000); }}

The above code works great, it does some jobs and then it sleeps for 15 sec, and then it does it again. The problem occurres when I get an exception.

The exception is caught alright, and sends me an mail, but the thred doesn’t continue in the loop after the exception, so the GetNewJob() method will never get executed again.

Any ideas what happens to the thread when exception hits, and how I can “save” the thread so it can continue?

  • 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-01T21:27:56+00:00Added an answer on June 1, 2026 at 9:27 pm

    Becasue you throw an exception, so the exception propagates on top of the stack and break execution of the source thread.

    catch (Exception exception)
    {
        var mail = new MailService();
        mail.SendExeption("Error has accured in GetJobs", exception);
        throw; //THIS LINE !
    }
    

    You can use an event to raise it, say, ExceptionCaught(..) and listen for that event inside your program.

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

Sidebar

Related Questions

I have an application that used Macro. In this macro I would like to
We have an application that runs a routine like: protected string _largeFile; Execute() //this
I have application that makes different queries with different results so the caching in
I have an application that was written in vanilla ASP.NET that I would like
I am executing SSIS packages from an application server that is different than the
I have a simple RMI 'compute' server application (similar to this ) that accepts
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have two application that need to talk to each other. App1 needs to

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.