what does "snapshot out of sync" mean?

hi i’m developing web game with ur Unity3d and SmartFoxServer technology.
as u provided nice example, it’s very comfortable to understand co-operation of both server and client.

but here i have a problem with my code.
plz read debug message below:

InvalidOperationException: Hashtable.Enumerator: snapshot out of sync.
System.Collections.Hashtable+Enumerator.FailFast () 
System.Collections.Hashtable+Enumerator.MoveNext () 
LobbyGUI.SetupRoomList ()   (at Assets\Game\Scripts\LobbyGUI.cs:206)
LobbyGUI.Awake ()   (at Assets\Game\Scripts\LobbyGUI.cs:66)

this exception happens when i typed username and press submit button in login user interface.
and strangely this exception happens often, not always.

and the code LobbyGUI.cs:66 is like this:

	private void SetupRoomList() {	
		List<string> rooms = new List<string>();

		foreach ( Room room in smartFox.GetAllRooms().Values ) {

			// Only show game rooms
			if ( !room.IsGame()) {
				continue;
			}

			Debug.Log("Room id: " + room.GetId() + " has name: " + room.GetName());

			rooms.Add(room.GetName());
		} //////////// this is line 66

		roomStrings = rooms.ToArray();
	}

this code is totally from example except i transported it to my own project.
i cannot understand why this exception happens and even i don’t know what “snapshot out of sync” means.

plz someone tell me how i can solve these problem.
i cannot go any further by the virtue of this bug thx…

Just a thought,

Are you managing the exceptions when your client cannot connect to your server?, are you managing timeouts from the server?

as I told you its just a thought as I’m not an expert in smartfox :(, but this might be a reason of that problem you are having, as it happens often :slight_smile:

well connection to the server is established in the previous step of writing username and password.
because smartFox.IsConnected() is true in login interface, so i think it’s totally safe to proceed
from connection step to login step.

but the connection status can be a problem as u said i will check it up again. smartFox.GetAllRooms() may throw exception :slight_smile:

thank you!

I ran into the same problem using two functions
one was an iterator through a hashtable.
The sub function was trying to save data in the hashtable.

function a() {
    for ( var name_str : String in myhash.Keys ) { 
           
            result_str = dostuff(name_str);
            
    }
}

function dostuff(name_str : String) {
    var result_str = myhash[name_str]

    myhash[name_str] = "try this";

    return result_str;
}

the solution that worked for me was:
don’t store data in the hashtable while I was iterating through it

I’m getting the same thing but all I’m doing is reading from a SortedList

for	(var key in globals.hidden.list.Keys) {
			globals.hidden.list[key].active = false;
		}

Oddly too this has only been a problem since moving to Unity 3 from 2.6