I have this code that is called when a button is pressed:
async void OnTapped(object sender, System.EventArgs e)
{
var btn = sender as ButtonTemplate;
if (btn == null)
return;
if (btn.Text == Settings.cc.ShortText())
return;
if (Counts.phaseTableSelectedCardCount != 0)
{
var canContinue = await this.DisplayAlert("Selector", "Changing this will remove all previously selected cards from the deck", "OK", "Cancel");
if (canContinue == false)
return;
}
var settingId = SetButtons(btn.Text);
//
// These updates take 1-3 seconds
//
App.DB.UpdateSelected(false);
App.DB.UpdateIntSetting(SET.Cc, settingId);
AddDetailSection();
}
public void AddDetailSection()
{
vm.IsBusy = true;
Change.cardSelection = true;
App.DB.GetData();
detailsLayout.Children.Clear();
detailsLayout.Children.Add(CreateDetailSection(null));
SetPageDetails();
vm.IsBusy = false;
}
After the button is pressed the SetButtons(btn.Text);
code changes the button colors. However I do not see the effect on the UI until 2-3 seconds later when these lines have executed,
App.DB.UpdateSelected(false);
App.DB.UpdateIntSetting(SET.Cc, settingId);
AddDetailSection();
Is there a way that the UI colors can change and the above three lines can run in the background?