Solved

Response from System.Diagnostics.Process.Start

Posted on 2006-11-25
7
208 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now