async void OnCloseButtonClicked(object sender, EventArgs e) { var answer = await DisplayAlert("Close poll", "Are you sure you want to close this poll?", "Yes", "No"); if (answer) { //If user confirm to close the poll, send the HTTP request activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; string httpTask = await Task.Run <string>(() => HttpRequestHandler.PostClosePoll(poll.pollID, adminAuth.Username, adminAuth.Password)); string httpResult = httpTask.ToString(); activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; if (httpResult == "Successfully closed poll!") { await DisplayAlert("Success", "Poll has been successfully closed!", "OK"); var page = App.Current.MainPage as rootPage; var pollPage = new pollPage(); page.changePage(pollPage); } else { await DisplayAlert("Failed", httpResult, "OK"); } } }