Recognize the process end

smiles

Well-known member
Joined
May 21, 2008
Messages
47
Programming Experience
Beginner
I create a simple form to call an process, is there anyway that the form can recognize that I have just ended that process :confused:
Thanks so much :)
 
Sorry for my late reply, I had tried this code to test what happen when I close that process, but it doesn't work (close process, and message box 'Yes', but it appear message box 'Yes' right away) :confused:
Use timer ?
VB.NET:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim psi As New System.Diagnostics.ProcessStartInfo("C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe")
        psi.RedirectStandardOutput = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.UseShellExecute = False
        Dim uls As System.Diagnostics.Process
        uls = System.Diagnostics.Process.Start(psi)
        If uls.HasExited Then
            MessageBox.Show("No")
        Else
            MessageBox.Show("Yes")
        End If
    End Sub
Thanks !!!
 
Did you actually read my post? I suggested the WaitForExit method and the Exited event. You ignored my suggestions and tried to use the HasExited property. Of course you see "Yes" immediately because immediately after starting the process you are testing whether it has exited and, of course, it hasn't. I've already told you what to use. If you aren't going to use them then I can't help any further.
 
VB.NET:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Process1.Start()
        Process1.WaitForExit()
        MessageBox.Show("yes")
    End Sub
WaitForExit() and it really waits to do the next command, in doubt with this so didn't try, sorry and thanks :eek:
 
Back
Top