bool WaitForPlayers() { string[] players = null; using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { if (State == MusState.FinishGame) { return(true); } players = null; while (players?.Length != 4) { players = c.GetConnectedUsers(generalData.GameName); if (players?.Length == 4) { State = MusState.MakeTeams; } else { if (Disposing || IsDisposed || State == MusState.FinishGame) { return(false); } Application.DoEvents(); Thread.Sleep(1000); Application.DoEvents(); } } } return(true); }
bool WaitForAllPlayersInNextRound() { while (true) { int round = -1; using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { if (State == MusState.FinishGame) { return(true); } var musData = c.GetMusData(generalData.GameName, generalData.TeamName, generalData.UserName); foreach (var t in musData.MusTeams) { if (round < 0) { if (t.RoundUserName1 != t.RoundUserName2) { break; } round = t.RoundUserName1; } if (t.RoundUserName1 != round || t.RoundUserName2 != round) { round = -1; break; } } } if (round > 0) { break; } else { if (Disposing || IsDisposed || State == MusState.FinishGame) { return(false); } Application.DoEvents(); Thread.Sleep(1000); Application.DoEvents(); } } return(true); }