title: C# Waiting for multiple threads to finish
body: <p>I have a windows forms app that I am checking all the serial ports to see if a particular device is connected.</p>
  
  <p>This is how I spin off each thread.  The below code is already spun off the main gui thread.</p>
  
  <pre><code>foreach (cpsComms.cpsSerial ser in availPorts)
  {
      Thread t = new Thread(new ParameterizedThreadStart(lookForValidDev));
      t.Start((object)ser);//start thread and pass it the port
  }
  </code></pre>
  
  <p>I want the next line of code to wait until all the threads have finished.
  I've tried using a <code>t.join</code> in there, but that just processes them linearly.  </p>