title: system.invalidoperationexception: collection was modified; enumeration operation may not execute. Need ideas?
body: <p>I'm getting this error from my C# Emulator,</p>
  
  <pre><code>Error en thread Room cycle task for room 1: 
  System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
  at System.Collections.Generic.HashSet`1.Enumerator.MoveNext()
  at Mercury.HabboHotel.Rooms.RoomManager.UnloadRoom(Room Room) in                        xampp\Emulator\HabboHotel\Rooms\RoomManager.cs:line 629
  at Mercury.HabboHotel.Rooms.Room.ProcessRoom() in c:\xampp\Emulator\HabboHotel\Rooms\Room.cs:line 807
  </code></pre>
  
  <p>Quick explanation, this emulator is for a flash game. The code it's referring too is such. RoomManager.cs line 629;</p>
  
  <pre><code>lock (Room.RoomChat)
              {
                  foreach (Chatlog current2 in Room.RoomChat)
                  {
                      current2.Save(Room.RoomId);
                  }
              }
              Room.Destroy();
  </code></pre>
  
  <p>It's the foreach line. Room.cs line 807,</p>
  
  <pre><code>if (this.IdleTime &gt;= 60/* &amp;&amp; usersQueueToEnter.Count == 0*/)
                      {
                          MercuryEnvironment.GetGame().GetRoomManager().UnloadRoom(this);
                          mIsIdle = false;
                          return;
                      }
  </code></pre>
  
  <p>It's the MercuryEnvironment.GetGame() Line to be exact. Basically, the first void I showed is meant to be saving a room chatlog and then 'destroying' the room which is just meaning no one is in it. The second part refers to an idle timer. If your character goes idle for too long, they update with a little 'Zzz' next to them, after a while they get kicked from the room. So, I'm not sure what is going on with this problem. Anyone have any ideas?</p>