title: Multi-threading on a foreach loop?
body: <p>I want to process some data. I have about 25k items in a Dictionary. IN a foreach loop, I query a database to get results on that item. They're added as value to the Dictionary.</p>
  
  <pre><code>foreach (KeyValuePair&lt;string, Type&gt; pair in allPeople)
  {
      MySqlCommand comd = new MySqlCommand("SELECT * FROM `logs` WHERE IP = '" + pair.Key + "' GROUP BY src", con);
      MySqlDataReader reader2 = comd.ExecuteReader();
      Dictionary&lt;string, Dictionary&lt;int, Log&gt;&gt; allViews = new Dictionary&lt;string, Dictionary&lt;int, Log&gt;&gt;();
      while (reader2.Read())
      {
          if (!allViews.ContainsKey(reader2.GetString("src")))
          {
              allViews.Add(reader2.GetString("src"), reader2.GetInt32("time"));
          }
      }
      reader2.Close();
      reader2.Dispose();
      allPeople[pair.Key].View = allViews;
  }
  </code></pre>
  
  <p>I was hoping to be able to do this faster by multi-threading. I have 8 threads available, and CPU usage is about 13%. I just don't know if it will work because it's relying on the MySQL server. On the other hand, maybe 8 threads would open 8 DB connections, and so be faster.</p>
  
  <p>Anyway, if multi-threading would help in my case, how? o.O I've never worked with (multiple) threads, so any help would be great :D</p>