My OnAppearing message is async and from that I call another async method which has some code that modifies the UI. I then do some work and finally modify the UI again.
Here's the code. However I am getting a warning message that confuses me. I added the warning code below.
protected async override void OnAppearing()
{
base.OnAppearing();
// actions
CreateListSectionAsync();
}
public async void CreateListSectionAsync()
{
// modify UI
// do some work that takes time
await Task.Run(() =>
{
Device.BeginInvokeOnMainThread(() =>
{
// modify UI
});
});
}
ListPage.xaml.cs(39,39): Warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. (CS1998)
Why am I getting this warning and how can I fix it?