Waiting for a process to halt before continuing

C

Chris

What would be the simplest way to make an app wait for one process to
finish before starting the next process?

Example
///

FileCopy(strPath & "test.mdb", strPath & "live.mdb")
Wait(Until FileCopy is Done) <---------------That is what I'm
looking for
Shell(someapp.exe)

///
I want someapp.exe to start only after the file has been copied
completely, not run asynchronously. I've done some reading on
CreateProcess and WaitForSingleObject but they seem way more
complicated(lengthy) then what I need for this problem. In my little
program I'll need this command 60 - 80 times is why I'm looking for
brevity.

Thanks for any ideas.

Chris
Hello World - Check
First App - Working on it
 
C

Cor Ligthert [MVP]

As long as you don't do this multithreading there is no need to check if the
filecopy is done.

This is the standard approach in a serial program.

If you use instead of Shell, "process.start" than there is in that a method
to wait until that is done.

Cor
 
C

Chris

Cor said:
As long as you don't do this multithreading there is no need to check if the
filecopy is done.

This is the standard approach in a serial program.

If you use instead of Shell, "process.start" than there is in that a method
to wait until that is done.

Cor

Thank you! I'm using it like this, and it seems to be working just
fine.

///
Dim myProcess As Process =
System.Diagnostics.Process.Start("c:\process1.exe")
myProcess.WaitForExit()
myProcess = System.Diagnostics.Process.Start("c:\process2.exe")
myProcess.WaitForExit()
myProcess = System.Diagnostics.Process.Start("c:\process3.exe")
myProcess.WaitForExit()
///

Chris
 
C

Chris

I'm having a problem now. The path to my program is giving me a 'file
not found' error.

If I do this-
Shell("myapp.exe /dump " & strPath & "\db.mdb")
it works perfectly

If I do this-
myProcess = System.Diagnostics.Process.Start("myapp.exe /dump " &
strPath & "\db.mdb")
it says file not found.

All I did was replaced 'shell' with the process.start method.

I think it has something to do with the switch '/dump'

Any thoughts?

Chris
 

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