private async Task UpdateProfile(ProfileModel.Datum model) { string ret = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { ret = WebService.UpdateProfile(model); }).ContinueWith(async t => { if (ret == "success") { StaticMethods.ShowToast("Profile Updated successfully!"); Navigation.PopModalAsync(); } else { StaticMethods.ShowToast("Failed to update profile!"); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
void BtnUpdate_Clicked(object sender, EventArgs e) { if (IsValidate()) { var model = new ProfileModel.Datum(); model.name = txtName.Text; model.email = txtEmail.Text; model.mobile_no = txtMobile.Text; model.website_url = txtWebUrl.Text; UpdateProfile(model); } else { DisplayAlert("Alert", "All fields are required!", "OK"); } }