?
Solved

Response from System.Diagnostics.Process.Start

Posted on 2006-11-25
7
Medium Priority
?
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 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