title: Parallel.For fail (C#)
body: <p>I wrote some code:</p>
  
  <pre><code>class Program
      {
          public const int count = 3000;
          static List&lt;int&gt; list = new List&lt;int&gt;();
          static void DoWork(int i)
          {            
              list.Add(i);
          }        
          static void Main(string[] args)
          {
              while (true)
              {
  
                  Stopwatch s = new Stopwatch();
                  s.Start();
                  Parallel.For(0, count + 1, DoWork);            
                  s.Stop();
                  Console.WriteLine("\n Elapsed: " + s.Elapsed.ToString());
                  Console.WriteLine("Expected: {0}", count + 1);
                  Console.WriteLine("count: {0}", list.Count);
                  Console.ReadKey();
                  list = new List&lt;int&gt;(); 
              }
          }
      }
  </code></pre>
  
  <p>but results are not expected(</p>
  
  <p>Not all of the cycles are finished before Console.WriteLine calls</p>
  
  <p>What is the problem with using Parallel.For?</p>