title: Wait for ANY thread to finish, not ALL
body: <p>I'm starting multiple threads and would like to know when <em>any</em> of then finishes. I know the following code:</p>
  
  <pre><code>foreach (Thread t in threads)
      t.Join();
  </code></pre>
  
  <p>But it will only wait for <em>all</em> threads together. That's much too late. I need to know when one thread finishes, even when other threads are still running. I'm looking for something equivalent to <code>WaitAny</code> only for threads. But I can't add code to all threads I'm monitoring, so using signals or other synchronisation objects is not an option.</p>
  
  <p><strong>Some clarification:</strong> I'm working on a logging/tracing tool that should log the application's activity. I can insert log statements when a thread starts, but I can't insert a log statement on every possible way out of the thread (multiple exit points, exceptions etc.). So I'd like to register the new thread and then be notified when it finishes to write a log entry. I could asynchronously <code>Join</code> on every thread, but that means a second thread for every monitored thread which may seem a bit much overhead. Threads are used by various means, be it a <code>BackgroundWorker</code>, <code>Task</code> or pool thread. In its essence, it's a thread and I'd like to know when it's done. The exact thread mechanism is defined by the application, not the logging solution.</p>