private async void fetchUsername() { App.Current.Dispatcher.Invoke(delegate { Usernames.Clear(); }); ObservableCollection <UserLobby> usernames = new ObservableCollection <UserLobby>(); try { var response = await ServerService.instance.client.GetAsync(Constants.SERVER_PATH + Constants.USERS_LOBBY_PATH + LobbyName); if (response.IsSuccessStatusCode) { StreamReader streamReader = new StreamReader(await response.Content.ReadAsStreamAsync()); String responseData = streamReader.ReadToEnd(); var myData = JsonConvert.DeserializeObject <List <String> >(responseData); foreach (var item in myData) { App.Current.Dispatcher.Invoke(delegate { usernames.Add(new UserLobby(item, item == ServerService.instance.username)); if (Bots.Contains(item)) { Bots.Remove(item); } }); } Usernames = usernames; string firstUser = findFirstNotBot(Usernames); IsGameMaster = ServerService.instance.username == firstUser; } else if (!response.IsSuccessStatusCode) { var message = await response.Content.ReadAsStringAsync(); ErrorServerMessage serverMessage = JsonConvert.DeserializeObject <ErrorServerMessage>(message); ShowMessageBox(serverMessage.message); } } catch (Exception e) { ShowMessageBox(e.Message); } }