Click to See Complete Forum and Search --> : Waiting for termination
Canada Bass
April 22nd, 1999, 08:34 AM
I am trying to make a Win 32 application(DOS only) that will launch a program and wait until it terminates in Visual C++ 5. It also has another thread that updates a file every minute(launched with _beginthread). The problem I run into is that I do not know how to launch a program and wait for it to terminate. Could someone please help me with this?
Thanks.
April 22nd, 1999, 08:40 AM
Try the WaitForSingleObject() API call.
Use the handle returned from _beginthread to identify the object to
wait for.
Canada Bass
April 22nd, 1999, 10:34 AM
...launch the application(and arguments) with _beginthread?
April 23rd, 1999, 07:25 AM
>>...launch the application(and arguments) with _beginthread?
You don't. I misunderstood. However, within an application you can
detect thread termination using WaitForSingleObject. The beauty of
this call is that the handle passed can be a handle to all manner of
things. You can lauch your application by calling CreateProcess, and
the handle returned will identify it. Then call WaitForSingleObject
passing the process handle and you will detect when the process has
ended. Hope this helps.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.