|
-
Jun 1st, 2000, 08:04 PM
#1
Thread Starter
New Member
The fact that someone started a thread to ask which is better, if/else or case switch bothers me a little. The fact that no one had the right answer makes me leary of asking this question here, but I have few other sources:
I am kluging the hell out of this code to get it to ftp to the mainframe. I have hunted and hunted and ftping seems to be something VB can handle in only the most superficial of manners.
My way around this is to get VB to launch the batch to spawn the ftp session. When I do this I grab the PID of the cmd that the batch runs in. What I want to do now is wait for that process to exit. I have developed another kluge for this, but I am starting to run out of duct tape, and neither of these methods are stable or robust enough to recover from an error.
My question is; what is the most robust way of waiting for the process to exit when you have not a handle, but a PID?
-Travis
Travis, BS in CSC
MQ/Series Administration
VB6E on NT4sp4
-
Jun 2nd, 2000, 01:16 AM
#2
Try WaitForSingleObject api. I used it in a batch processing app, and it has never failed.
Code:
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Const WAIT_TIMEOUT = &H102&
'a little piece of code
retVal = WaitForSingleObject(ProcessHandle, 0)
If retVal <> WAIT_TIMEOUT Then
' app is finished
' close the handle of the process
Call CloseHandle(ProcessHandle)
End If
-
Jun 2nd, 2000, 01:25 AM
#3
Oh yeah, I forgot something.
My app periodically calls this routine to check if it is finished yet. It goes on doing other stuff in the mean time.
If you want to wait until the other program is finished, and don't want to check periodically, you could pass INFINITE instead of 0 for dwMilliseconds. But your app will freeze until the other prog is finished (no repainting of the forms either).
Public Const INFINITE = &HFFFF
retVal = WaitForSingleObject(ProcessHandle, INFINITE)
' if you get here the process is finished
-
Jun 2nd, 2000, 01:35 AM
#4
Thread Starter
New Member
Handle same as PID?
I thought WaitforSingleObject&() was using a handle that I had to the process, one from a CreateProcess&().
I was using Wait when I was using Create, but Create would spawn a shell with no environmental variables inherited. I would preffer using Create if someone knows how to fix that. Right now I am using shell().
I will play around with Wait.
-Travis
Travis, BS in CSC
MQ/Series Administration
VB6E on NT4sp4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|