ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Waiting for program completion in Visual Basic 2008

(1/2) > >>

wreckedcarzz:
I am trying to run multiple (anywhere from 2 to 6) programs after the user clicks a button. I can do that just fine, with the exception of them all starting at once. I have tried using the Shell command and using that to Wait, however VB9 doesn't allow that to do anything, so I am stuck with Process.Start("myprocess.exe").

I need to know how to wait for the first program to complete its work and close before executing the next (I don't want to get into loops or anything timer based, if that is possible). I don't want it to time out and run the next program- it has to wait for the program to close to work properly.

Anyone?

-Brandon

mwb1100:
If I understand your question right, then all you have to do is call the WaitForExit() method on the Process object returned by Process.Start( "myprocess.exe").  Something like:


--- Code: vb.net ---Dim proc as Process proc = Process.Start( "myprocess.exe")proc.WaitForExit() proc = Process.Start( "myprocess2.exe")proc.WaitForExit() ' and so on...

wreckedcarzz:
Yes, exactly what I was looking for! Thanks!!! :)

Renegade:
Just a note, but I think that you should make sure that you spin that code off into another thread and poll it for completion.

Otherwise you may end up with some nastiness.

mahesh2k:
 ;D
i accidently thought it means logic completion that could ruin alll human programmers and will start the AI rage like this one.
http://www.swatkats.us/unlikely_alloys

:)

Navigation

[0] Message Index

[#] Next page

Go to full version