title: Different summation results with Parallel.ForEach
body: <p>I have a <code>foreach</code> loop that I am parallelizing and I noticed something odd.  The code looks like</p>
  
  <pre><code>double sum = 0.0;
  
  Parallel.ForEach(myCollection, arg =&gt;
  {
       sum += ComplicatedFunction(arg);
  });
  
  // Use sum variable below
  </code></pre>
  
  <p>When I use a regular <code>foreach</code> loop I get different results.  There may be something deeper down inside the <code>ComplicatedFunction</code> but it is possible that the <code>sum</code> variable is being unexpectantly affected by the parallelization?</p>