The problem is that you (at least in the code you posted) are calling WaitForExit()
on the UI thread. The UI thread is responsible for redrawing the window, so if you block it, by calling WaitForExit()
for example, its not redrawing the ui and the app appears to be frozen.
What you need to do is call it on another thread or on the thread pool, I recommend using Tasks:
Task.Run( Sub()
Dim p As Process = Process.Start(pInfo)
p.WaitForExit()
End Sub)
However, since you're not doing anything with the results of the Process.Start()
call, you can also consider not calling WaitForExit()
at all.
Since you're using VS2013 you can also use the await operator to wait for the process to finish:
await Task.Run( Sub()
Dim p As Process = Process.Start(pInfo)
p.WaitForExit()
End Sub)
Note that you also have to add the async
keyword to the surrounding method as well