Home All Groups Group Topic Archive Search About

Waiting for a process to halt before continuing

Author
28 Dec 2006 8:17 AM
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

Author
28 Dec 2006 8:27 AM
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


Show quoteHide quote
"Chris" <chriskn***@gmail.com> schreef in bericht
news:1167293829.063297.248090@a3g2000cwd.googlegroups.com...
> 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
>
Author
28 Dec 2006 6:09 PM
Chris
Cor Ligthert [MVP] wrote:
> 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
Author
28 Dec 2006 7:30 PM
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
Author
29 Dec 2006 5:03 AM
Cor Ligthert [MVP]
Chris,

Have a look at the differet samples we made.

http://www.vb-tips.com/dbpages.aspx?ID=7ecd7359-0114-43bb-8f3a-14d6b93856e8

Be aware that the side is under construction at the moment.

Cor

Show quoteHide quote
"Chris" <chriskn***@gmail.com> schreef in bericht
news:1167334210.651820.23690@42g2000cwt.googlegroups.com...
> 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
>
Author
29 Dec 2006 8:08 AM
Chris
Cor Ligthert [MVP] wrote:
> Chris,
>
> Have a look at the differet samples we made.
>
> http://www.vb-tips.com/dbpages.aspx?ID=7ecd7359-0114-43bb-8f3a-14d6b93856e8
>
> Be aware that the side is under construction at the moment.
>
> Cor
>

Thanks Cor!

I finally realized that I needed to seperate the program from the
arguments with commas.  It's working well now.

Chris