DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Waiting for program completion in Visual Basic 2008  (Read 7,899 times)

wreckedcarzz

  • Still lurking. Still an anthro.
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,629
    • Participated in NANY Challenge Twice
    • Coding Snacks
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Waiting for program completion in Visual Basic 2008
« on: February 11, 2008, 06:20 AM »
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

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
Re: Waiting for program completion in Visual Basic 2008
« Reply #1 on: February 11, 2008, 07:15 AM »
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: (vbnet)
Dim proc as Process

proc = Process.Start( "myprocess.exe")
proc.WaitForExit()

proc = Process.Start( "myprocess2.exe")
proc.WaitForExit()

' and so on...

« Last Edit: February 11, 2008, 07:57 AM by mwb1100 »

wreckedcarzz

  • Still lurking. Still an anthro.
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,629
    • Participated in NANY Challenge Twice
    • Coding Snacks
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: Waiting for program completion in Visual Basic 2008
« Reply #2 on: February 11, 2008, 10:52 PM »
Yes, exactly what I was looking for! Thanks!!! :)

Renegade

  • Tell me something you don't know...
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,291
    • Participated in NANY Challenge Three Times
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: Waiting for program completion in Visual Basic 2008
« Reply #3 on: February 20, 2008, 09:21 PM »
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.
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

mahesh2k

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,426
    • Participated in NANY Challenge Twice
Re: Waiting for program completion in Visual Basic 2008
« Reply #4 on: February 21, 2008, 01:24 PM »
;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

:)

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: Waiting for program completion in Visual Basic 2008
« Reply #5 on: February 21, 2008, 03:23 PM »
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.
DON'T POLL!

If he's doing a GUI and doesn't want to lock that up, sure, put program launch in a work thread. But don't frigging poll, have the worker-thread post a "I'm done" message to the GUI thread. Polling is evil and lame, except for a very small set of problems.

- carpe noctem

Original address: https://www.donationcoder.com/forum/index.php?topic=12252.0