Link to home
Start Free TrialLog in
Avatar of dinesh_bali
dinesh_bali

asked on

Response from System.Diagnostics.Process.Start

Hi,

I am using .Net 2005 and I am working on Windows application

If I am calling any other application from my application using

System.Diagnostics.Process.Start(Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe");

This is starting my application made in .Net 2003

I want that when this application exists then I must know, that the application I opened is closed now

Can I find this in my application

Kind Regards,
Avatar of Gautham Janardhan
Gautham Janardhan

System.Diagnostics.Process FProcess =
                new System.Diagnostics.Process();
            FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe"
            FProcess.Start();
             FProcess.Kill();//if u want to kill the other process
            FProcess.WaitForExit() //waits till it exists
            FProcess.HasExited // gets whether the other application has exited

and u get many other stuff under FProcess
Avatar of dinesh_bali

ASKER


Thanks for your response.

Can I get from process that the process is completed and now I can continue with my task even if process is not killed.

Many thanks once again
You can also do it with an event.

FProcess.EnableRaisingEvents=true;

And then

private void FProcess_Exited(object sender, System.EventArgs e)
    {
   
    }

Make sure that you have a delegate event handler set up

e.g.
in a form
      this.FProcess.SynchronizingObject = this;
      this.FProcess.Exited += new System.EventHandler(this.FProcess_Exited);
Hi,

I want to do something like this

  if(FProcess.WaitForExit())
            {
                MessageBox.Show("Exited");
            }//waits till it exists
            if(FProcess.HasExited())
            {
                MessageBox.Show("has exited");
            }

How to do this and also, this is error.

Can I get from process that the process is completed and now I can continue with my task even if process is not killed.

Many Thanks
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
private void FProcess_Exited(object sender, System.EventArgs e)
    {
       MessageBox.Show("Prcess has Exited");

    }
Many Thanks