Waiting for a process to complete 
Author Message
 Waiting for a process to complete

Hi,
 I've been using the ShellExecute() API to execute a
process. I currently do a Sleep() to wait for it to
complete, but it is not accurate. Is there an accurate way
to know when the process has completed.
Thanks,
Sucharit


Sun, 20 Feb 2005 17:30:21 GMT  
 Waiting for a process to complete

Quote:

>  I've been using the ShellExecute() API to execute a
> process. I currently do a Sleep() to wait for it to
> complete, but it is not accurate. Is there an accurate way
> to know when the process has completed.

You should use "CreateProcess" and wait on the hProcess-Handle in the
PROCESS_INFORMATION-Structure.

CreateProcess(..., &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);

--
Greetings
  Jochen



Sun, 20 Feb 2005 17:38:32 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Waiting for asyncronous function to complete in curr thread

2. Waiting for threads to complete.

3. Waiting for asyncronous function to complete in curr thread

4. wait for winexec to complete?

5. Waiting for install to complete

6. Waiting for a thread to complete

7. Waiting for an App to complete

8. Notifying workstation a server process is completed

9. When is Process Complete?

10. How to wait on a process termination...

11. Q: waiting processes and signals

12. ShellExecute and killing a process waiting for input

 

 
Powered by phpBB® Forum Software