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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:01:06+00:00 2026-05-13T07:01:06+00:00

I have a program that executes another program and the main program continues when

  • 0

I have a program that executes another program and the main program continues when that program is finished.

Process p = Process.Start("program2.exe");

while (!p.HasExited)
    Thread.Sleep(10000);

if (p.HasExited)
{
    // Execute more code
}

This works great as when I run the program. But does not work when it is used as a scheduled task in windows. this part never executes

if (p.HasExited)
{
    // Execute more code
}

Can’t seem to find a way to debug this.
I’ve been stuck on this program for a week now.

  • 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-13T07:01:06+00:00Added an answer on May 13, 2026 at 7:01 am

    Your code would be simpler if you assume that once p.HasExited is true that it stays that way. You can then remove the if statement. Then there’s only three remaining ways I can see that your code can give the result you see:

    1. The second process never exits. Can you see it in Task manager?
    2. Your code throws an exception. Are you logging exceptions somewhere?
    3. The second process exits, but never reports HasExited.

    Can you try to investigate and eliminate 1 and 2 first? It is a good idea to look at the simple alternatives first.

    Update: From the comments Andrew Keith also suggested that the code might not be being executed at all. Insert log statements liberally so you can see exactly what is going on. Log to a file for example.

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

Sidebar

Related Questions

I have a Python program that executes a large MySQL statement. How do I
I have a Java program that executes from Spring Qquartz every 20 seconds. Sometimes
I have a program that is executed by another program. The program that is
I have a Java program that uses reflection to find and invoke the main(String[]
I have a JFrame that is the main class of the program. I want
I have to write program that create process using pipe() . My first task
How do I check if another application is busy? I have a program that
I have a Qt application that launches two threads from the main thread at
I have this program that should execute a piece of code base on the
I have program that requires Python 3, but I develop Django and it uses

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.