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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:26:35+00:00 2026-05-28T13:26:35+00:00

I am making form application, that also runs a console process on different thread.

  • 0

I am making form application, that also runs a console process on different thread. Basically I need to unblock a button after application has exited. Before I made event handler the process after completion just stopped, but now, after event the applications itself is killed.

Here is the code for making process run:

public void CallConsole()//This Calls the console application
{
    Thread.CurrentThread.IsBackground = true;
    Process p = new Process();
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.FileName = filename;
    if (checkBox1.Checked)
       p.StartInfo.CreateNoWindow = true;
    p.EnableRaisingEvents = true;
    p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
    p.ErrorDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
    p.Exited += new EventHandler(p_Exited);
    p.Disposed += new EventHandler(p_Exited);
    p.Start();
    p.BeginErrorReadLine();
    p.BeginOutputReadLine();
}

I tried to work with Thread.IsBackground property, but that didn’t change anything

Here’s the event handler itself:

void p_Exited(object sender, EventArgs e)//Process on exit or disposed will make button1 avalable
{
    button1.Enabled = true;
}

Any ideas why the application after adding

p.EnableRaisingEvents = true;

is now killed, not just the process?

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

    The problem here was that

    void p_Exited(object sender, EventArgs e)//Process on exit or disposed will make button1 available
    {
        button1.Enabled = true;
    }
    

    required invocation and did not have any sort of error handling. Once I added another function that checks button1.InvokeRequired and in case it does calls itself again trough invocation it worked out great

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

Sidebar

Related Questions

When your application has a view that is only accessible after submitting another form
EDITED: Java httpPost into .asp form I am making an application that will display
I'm making a windows form application that uses threads, the threads is running and
I'm making a C# windows form application that needs to parse data from an
I'm making a simple form that is to step through a program iteratively. How
I'm having a little bit of trouble making a sticky form that will remember
I'm making a Windows Form Application with VS 2010. I've added a ProgressBar to
I am making an application that allows users to upload a file in a
I'm building a marketplace application that uses PayPal Express. I've got a form for
I have an ASP.Net web application that is deployed to a number of different

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.