Solved

Response from System.Diagnostics.Process.Start

Posted on 2006-11-25
7
216 Views
Last Modified: 2010-04-16
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,
0
Comment
Question by:dinesh_bali
  • 3
  • 3
7 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18011499
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
0
 

Author Comment

by:dinesh_bali
ID: 18011504

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
0
 
LVL 29

Expert Comment

by:Nightman
ID: 18011509
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);
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:dinesh_bali
ID: 18011534
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
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 18011541
s as nightnman said that would be an option if u dont want to raise events but handle this separately in another thread then u could start a thread after u start the process and and in the function which is called by the thread have an infinite loop like



while (!FProcess.HasExcited)
{

}
 Application.Exit()


but this is necessary if u want to handle ur new process in a new thread ...if u dont want this to be a new process u coudl raise the even as


 Comment from gauthampj
Date: 11/25/2006 08:30PM IST
 Your Comment  


System.Diagnostics.Process FProcess =
                new System.Diagnostics.Process();
            FProcess.StartInfo.FileName = Application.StartupPath + @"\Decrypt\vb_passwordDcrypt.exe"
            FProcess.Start();
            FProcess.SynchronizingObject = this;
            FProcess.Exited += new System.EventHandler(this.FProcess_Exited);

           
 
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18011547
private void FProcess_Exited(object sender, System.EventArgs e)
    {
       MessageBox.Show("Prcess has Exited");

    }
0
 

Author Comment

by:dinesh_bali
ID: 18011606
Many Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can i use linq for parsing string datetime to real datetime? 16 49
C# Gridview 1 48
How come this regular expression allows "e"? 14 45
Name Space error VS2015 1 25
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question