Re: Asynchronous Process.WaitForExit()?
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Wed, 14 Jun 2006 17:48:24 -0700
"Douglas Harber" <--remove-this--dh-nospam@xxxxxxxxx> wrote in message
news:%23A5hDNAkGHA.5108@xxxxxxxxxxxxxxxxxxxxxxx
Is there any way to do an asynchronous wait for a process to exit? My
application needs to monitor when processes it launched have completed and
take further action. However, the app can launch processes essentially
randomly (with respect to any other launched processes and/or their
completion). The current implementation has to create a thread per process
simply to wait for that process to exit and fire an event back into the
main thread. It would be a whole lot simpler if there was a
BeginWaitForExit() method on Process to allow my app to be notified
asynchronously as each process terminated.
Is there any way to emulate that kind of functionality? So far, I'm
missing it.
Take a look at ThreadPool.RegisterWaitForSingleObject. This uses a single
thread pool thread to wait on up to 64 handles at once, notifying you via
callback when the object is signalled or a timeout occurs.
In fact, it's not clear to me that you can asynchronously wait on any
signalable Win32 object in the elegant generalized fashion of Win32.
You can't. Win32 waits are strictly synchronous - any semblance of an async
wait is accomplished with the help of a worker thread.
Am I overlooking some functionality that's available in .NET?
ThreadPool.RegisterWaitForSingleObject has been available since 1.0.
-cd
.
- References:
- Asynchronous Process.WaitForExit()?
- From: Douglas Harber
- Asynchronous Process.WaitForExit()?
- Prev by Date: Re: .NET Frameowrk's interaction with the Windows OS
- Next by Date: how to protect my codes
- Previous by thread: Asynchronous Process.WaitForExit()?
- Next by thread: Re: Asynchronous Process.WaitForExit()?
- Index(es):