I have two C++ applications:
-
calc – computationally intensive, reads config from a file
-
ui – provides user friendliness. Transforms the choices the user makes in a UI into a config, launches calc and when calc finishes, displays the results.
I would like in ui to launch several instances of calc and wait for all of them to finish, then process the results of all. The question is, how can I wait for 8 simultaneously launched processes to finish? I googled around a bit but reached no conclusion. spanwl with P_NOWAIT seemed promising, but there seems to be no easy (“built-in”) way of seeing whether the process has already finished.
Any help is much appreciated,
Daniel
If you create the processes by calling CreateProcess, you will get back a process handle that you can wait on. To wait on multiple handles at once, use WaitForMultipleObjects function. This function has a limit – it can only wait for MAXIMUM_WAIT_OBJECTS (which was 64 for XP, not sure what it’s in Win7) handles at a time.