UPDATE
Actually this wasn't a great answer. As Henk pointed out in my comments, when you call Process.Start()
that's not a blocking call. You have to explicitly set Process.EnableRaisingEvents
to true
, and handle the Exited
event. I'm not sure if the Exited
event is fired in the calling thread (I doubt it, but you should check), but the point is starting a process isn't a blocking call, so you don't need more threads doing the waiting.
See this similar answer for more details: Async process start and wait for it to finish
PREVIOUS ANSWER
Fire off your threads (limited to your max number of threads), and have them run the external exe using the Process.Start()
method. Make sure you set them to wait for the process to finish. When the processes finish, have the threads use something like Interlocked.Increment()
to increment a counter variable that you can read from your main form code. Better still, have those threads call a callback delegate (e.g. Action<T>
), which will in turn check for this.InvokeRequired
before doing the actual work.