Example #1
0
 public void StartRoom(Room room)
 {
     StartedRooms.Add(room);
     foreach (RoomPlayer player in room.RoomPlayers)
     {
         Players.TryAdd(player.UserName, "");
     }
 }
Example #2
0
        public async Task Update()
        {
            List <Task <Room> > tasksList = new List <Task <Room> >();

            while (!NonStartedRoom.IsEmpty)
            {
                Room tempRoom;
                NonStartedRoom.TryTake(out tempRoom);
                tasksList.Add(UpdateNonStartedRoom(tempRoom));
            }

            var nonStartedRooms = await Task.WhenAll(tasksList);

            foreach (Room room in nonStartedRooms)
            {
                if (room != null)
                {
                    NonStartedRoom.Add(room);
                }
            }

            tasksList.Clear();

            while (!StartedRooms.IsEmpty)
            {
                Room tempRoom;
                StartedRooms.TryTake(out tempRoom);
                tasksList.Add(UpdateStartedRoom(tempRoom));
            }

            var startedRooms = await Task.WhenAll(tasksList);

            foreach (Room room in startedRooms)
            {
                if (room != null)
                {
                    StartedRooms.Add(room);
                }
            }
        }