title: Multithreaded foreach
body: <p>I have list of ReferenceIDs (string) in a dataset. These ReferenceIDs can have values like this ("CQ1258891","CQ1258892","CQ1258893"....""CQ1258993"). I have a logic in my code to send a mail for each ReferenceIDs. </p>
  
  <p>As of now I am looping through the every ReferenceID synchronously. Due to which, it take more time  to send every mail. <em>I have been using .NET 3.0, so I dont have option to use TPL in .NET 4.0.</em></p>
  
  <p>I have been looking for a multithreaded machanism to send the mails for every ReferenceID asynchronously. As of now, I have tried the following code but it's not working as expected.</p>
  
  <pre><code>foreach (DataRow row in qrefSet.Tables[0].Rows)
  {
      string refId = Convert.ToString(row["ReferenceID"]);
      if (!string.IsNullOrEmpty(refId))
      {
          Thread thread = new Thread(() =&gt; apeDBAdapter.SendEmail(personId, refId, parentReferenceID, customerName, queueId));                                    
          thread.Start();
      }
  }
  </code></pre>
  
  <p>Please share the effective machanism to achieve multithreaded foreach loop for my implementation.</p>
  
  <p>Thanks,
  Sriram</p>