The name may be a little misleading, my question is more about why it works in this weird way.
So, I have activity with a layout that has a TextView and ListView. I have a long asynchronous method that prepares data for display in a list. So, the source code looks like this:
protected async override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.MyView);
await SetupData();
}
private async Task SetupData(){
Task.Run(async () => {
var data = await new SlowDataLoader().LoadDataAsync();
});
}
It works, in a sense, that it runs without errors. However, activity is displayed as a blank screen, and even a textual representation is displayed only after a certain delay. Thus, it seems that the task is not actually running asynchronously. Setting ConfigureAwait (false) for both pending calls did not help. Moving a SetupData () call to OnPostCreate, OnResume, and OnPostResume has no effect. The only thing that made TextView display immediately and display the list later when the data was received:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.MyView);
new Handler().PostDelayed(async ()=>{
await SetupData();
}, 100);
}
So the question is why not
await SetupData().ConfigureAwait(false);
? , , ( http://www.wintellect.com/devcenter/paulballard/tasks-are-still-not-threads-and-async-is-not-parallel) SetupData , ?
p.s. , , - . .