title: Queue ForEach loop throwing InvalidOperationException
body: <p>I haven't used <code>Queues&lt;T&gt;</code> to any real degree before, so I might be missing something obvious. I'm trying to iterate through a <code>Queue&lt;EnemyUserControl&gt;</code> like this (every frame):</p>
  
  <pre><code>foreach (var e in qEnemy)
  {
       //enemy AI code
  }
  </code></pre>
  
  <p>When an enemy dies, the enemy user control raises an event I've subscribed to and I do this (the first enemy in the queue is removed by design): </p>
  
  <pre><code>void Enemy_Killed(object sender, EventArgs e)
  {      
       qEnemy.Dequeue();
  
       //Added TrimExcess to check if the error was caused by NULL values in the Queue (it wasn't :))
       qEnemy.TrimExcess();
  }
  </code></pre>
  
  <p>However, after the Dequeue method is called, I get an <code>InvalidOperationException</code> on the <code>foreach</code> loop. When I use <code>Peek</code> instead, there are no errors so it has to do something with the changing of the Queue itself since Dequeue removes the object.
  My initial guess is that it's complaining that I'm modifying a collection which is being iterated by the Enumerator, but the dequeuing is being performed outside the loop? </p>
  
  <p>Any ideas what could be causing this issue?</p>
  
  <p>Thanks</p>