title: System.ArgumentException when locking
body: <p>In my real application I need to iterate collection, but it can be changed from other thread. So I need to copy collection to iterate on it. I reproduced this problem to small example, but apparently my lack of understanding of locks and threads results in <code>System.ArgumentException</code>. Tried different things with lock, but result is the same. </p>
  
  <pre><code>class Program
  {
      static List&lt;int&gt; list;
      static void Main(string[] args)
      {
          list = new List&lt;int&gt;();
          for (int i = 0; i &lt; 1000000; i++)
          {
              list.Add(i);
              if (i == 1000)
              {
                  Thread t = new Thread(new ThreadStart(WorkThreadFunction));
                  t.Start();
              }
          }
      }
  
      static void WorkThreadFunction()
      {
          lock (list)
          {
              List&lt;int&gt; tmp = list.ToList();  //Exception here!
              Console.WriteLine(list.Count);
          }
      }
  }
  </code></pre>