private async void Start_Click(object sender, RoutedEventArgs e) { Uri resourceAddress; // The value of 'AddressField' is set by the user and is therefore untrusted input. If we can't create a // valid, absolute URI, we'll notify the user about the incorrect input. if (!Helpers.TryGetUri(AddressField.Text, out resourceAddress)) { rootPage.NotifyUser("Invalid URI.", NotifyType.ErrorMessage); return; } Helpers.ScenarioStarted(StartButton, CancelButton, OutputField); rootPage.NotifyUser("In progress", NotifyType.StatusMessage); try { IHttpContent jsonContent = new HttpJsonContent(JsonValue.Parse("{\"score\": 100, \"enabled\": false}")); HttpResponseMessage response = await httpClient.PostAsync(resourceAddress, jsonContent).AsTask(cts.Token); await Helpers.DisplayTextResultAsync(response, OutputField, cts.Token); rootPage.NotifyUser("Completed", NotifyType.StatusMessage); } catch (TaskCanceledException) { rootPage.NotifyUser("Request canceled.", NotifyType.ErrorMessage); } catch (Exception ex) { rootPage.NotifyUser("Error: " + ex.Message, NotifyType.ErrorMessage); } finally { Helpers.ScenarioCompleted(StartButton, CancelButton); } }