public async Task GetUserList() { usList.Items.Clear(); using (HttpClient client = new HttpClient()) { string responce = await client.GetStringAsync(MainFunc.ip + "/user_list"); UsersList = MainFunc.usersListHandler(responce); if (UsersList == null) { MessageBox.Show("Ошибка"); } else { foreach (User item in UsersList) { string usType = ""; if (item.perms == 0) { usType = "обычный пользователь"; } if (item.perms == 1) { usType = "администратор"; } usList.Items.Add("ФИО: " + item.fio + " \n Email: " + item.email + " \n Телефон: " + item.phone + " \n Тип пользователя: " + usType + ""); } } } }
public async Task GetUserList() { using (HttpClient client = new HttpClient()) { string responce = await client.GetStringAsync(MainFunc.ip + "/user_list"); UsersList = MainFunc.usersListHandler(responce); } }
public async Task GetUserList() { try { using (HttpClient client = new HttpClient()) { string responce = await client.GetStringAsync(MainFunc.ip + "/user_list"); UsersList = MainFunc.usersListHandler(responce); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!"); } }