async Task GetMonkeysAsync() { if (IsBusy) { return; } IsBusy = true; try { var client = new HttpClient(); var json = await client.GetStringAsync("https://montemagno.com/monkeys.json"); var all = Monkey.FromJson(json); Monkeys.ReplaceRange(all); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Something is wrong", "OH MY GOODNESS! :(", "OK"); } finally { IsBusy = false; } }
async Task GetMonkeysAsync() { if (IsBusy) { return; } try { IsBusy = true; var monkeys = await DataService.GetMonkeysAsync(); Monkeys.ReplaceRange(monkeys); Title = $"Monkey Finder ({Monkeys.Count})"; } catch (Exception ex) { Debug.WriteLine($"Unable to get monkeys: {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } finally { IsBusy = false; } }