Question Create an event when a process finishes

Billie1123

Member
Joined
Oct 24, 2009
Messages
11
Programming Experience
Beginner
Hi there,

I just wanted to know how to create an event which runs when a proccess finishes.

First, the program launches a batch file, so in the task manager, it appears as "CMD.EXE".

So, the event goes on when the CMD is over.

I'm not sure about what code should I use to do so.

any help ?
 
mmm ok.

I've found a solution using the waitforExit method.


Public Class form1



Private Sub executebatch() Handles Button3.Click

Dim Proceso As New Process()

'set process name or path
Proceso.StartInfo.FileName = batchdir.Text

Proceso.StartInfo.Arguments = ""
Proceso.Start()

Proceso.WaitForExit()

WebBrowser2.Navigate("google.es")

End Sub

End Class
 
You really can't use the WaitForExit method in UI thread unless you know/expect the process to finish within a second, because it blocks the thread and prevent the application from reponding to Windows messages. In this case you can run the process and wait for it in a background worker thread.
 
Back
Top