Launch another application and wait for it to complete.

S

Shelby

Hi,
if I launch another application in my vb code, how can I wait for it to
complete first?

Dim myProcess As Process
myProcess = New Process
myProcess.Start("test.exe")
' I want to wait for test to complete and continue with other codes
myProcess = Nothing

Thanks
Shelby
 
T

Tom Shelton

Hi,
if I launch another application in my vb code, how can I wait for it to
complete first?

Dim myProcess As Process
myProcess = New Process
myProcess.Start("test.exe")
' I want to wait for test to complete and continue with other codes
myProcess = Nothing

Thanks
Shelby

myProcess.WaitForExit()
 
S

Shelby

Hi Tom,
it raise an error:
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.dll
Additional information: No process is associated with this object.
 
K

Ken Tucker [MVP]

Shelby,

You are calling waitforexit before you dispose of it? Try this.

Dim p As Process = Process.Start("Notepad.exe")

p.WaitForExit()

p = Nothing



Ken

----------------------------
 
S

Shelby

Hi Ken,
thanks for that..

Shelby

Ken Tucker said:
Shelby,

You are calling waitforexit before you dispose of it? Try this.

Dim p As Process = Process.Start("Notepad.exe")

p.WaitForExit()

p = Nothing



Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top