public void SetUserState(ICollection <long> states, Zeze.Net.Binary statex) { lock (this) // 简单使用一下这个锁。 { UserStates.Clear(); UserStates.AddRange(states); UserStatex = statex; } }
void HandleJoinRoomCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { var newRoom = (RoomInfo)e.UserState; lock (_locker) { _roomInfo = newRoom; RoomName = newRoom.Name.ToUpper(); UserStates.Clear(); Start(); } }