There are more elegant ways to wait for the various concurrent threads to finish their work. The
WaitForThreadsToDie procedure is easy to understand, but is not as elegant as expected.
Now, we are going to make some changes to the code in order to use event wait handles instead of using a loop to check for the threads that are alive:
[STAThread]with the following line (before the
// The AutoResetEvent instances array private AutoResetEvent praoAutoResetEventArray;