"Ben Voigt" <rb*@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
|
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
| news:ef**************@TK2MSFTNGP04.phx.gbl...
| >
| > "colson" <ch******@gmail.com> wrote in message
| > news:11**********************@c74g2000cwc.googlegr oups.com...
| > |I know how to create a new process using System.Diagnostics.Process and
| > | wait for the process to end using WaitForExit(). How do I wait for
| > | multiple processes? Is there an equivalent to WaitForMultipleObjects
| > | under .NET?
| > |
| > | Thanks
| > |
| >
| > Yes there is an equivalent but it's not applicable here,
| > WaitForMultipleObjects waits for kernel objects to be signaled, while
| > WaitForExit waits for a processes to exit. All you need to do is create
a
| > separate thread for each process you need to start and wait for.
|
| Yeeech. Processes are kernel objects, and WaitForMultipleObjects handles
| them just fine.
Sorry, bad wording, I didn't mean to suggest that processes aren't kernel
objects.
|
| WaitHandle.WaitAll would work if Process had a WaitHandle property. But
it
| doesn't, and the ProcessWaitHandle class is internal to System.dll.
That's what I meant when I said it's not applicable here, there is no
publically exposed WaitHandle, 'would work if .. " isn't very usefull here.
| However, if you can get a WaitHandle from somewhere (WaitHandle is
abstract
| so new WaitHandle() won't work), you can reassign its Handle property to
the
| Process object's Handle property, and then use WaitHandle.WaitAll.
|
Sure you can do this by grabing the process handle, but it isn't that simple
as it may look like if you want to make it safe and solid. Just look at the
WaitForExit to get an idea of what (partly) should be done.
| Or get the process objects' Handle properties, stuff 'em into an array,
and
| p/invoke WaitForMultipleObjects.
|
|
http://pinvoke.net/default.aspx/kern...leObjects.html
|
No, thanks, I stay with my suggestion - one thread per process (I suppose
the OP isn't going to start hundreds of process that way), I prefer not to
go down a PInvoke hack when I don't have to.
Willy.