Hi, I am new to Xamarin Forms and I have inherited an app that does something like:
void BtnSubmit_Clicked (object s, EventArgs a)
{
if (editing) {
Device.StartTimer (TimeSpan.FromSeconds (1), () => {
Navigation.PopAsync ();
return false;
});
} else {
Device.StartTimer (TimeSpan.FromSeconds (1), () => {
Navigation.PushAsync (new OurCustomPage ());
Device.StartTimer (TimeSpan.FromSeconds (2), () => {
Navigation.RemovePage (this);
return false;
});
return false;
});
}
}
I find this code confusing and want to rewrite it to:
async void BtnSubmit_Clicked (object s, EventArgs a)
{
if (editing)
{
await Navigation.PopAsync();
} else {
await Navigation.PushAsync(new OurCustomPage ());
Navigation.RemovePage(this);
}
}
Could anyone tell me if that would be a problem? I have been told that sometimes delays are necessary to prevent the app from freezing / choking on UI changes but i am not sure how to create test conditions that would reproduce any problem with my desired approach.
Thank you in advance!