Solved

Response from System.Diagnostics.Process.Start

Posted on 2006-11-25
7
212 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

773 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