Why parent task finishes before his children tasks?
By : Кирилл Мышьяков
Date : July 30 2020, 04:00 AM
like below fixes the issue I think, I found a reason: "Parent tasks implicitly prevent child tasks from attaching to them if they are created by calling the Task.Run method." So, I shouldn't use Task.Run(), I should use Task.Factory.StartNew() instead.
Asynchronous parent task with synchronous children tasks
By : user5235760
Date : March 29 2020, 07:55 AM
Hope that helps Using C# 5 async-await, this would be quite simple: run the code that needs to run on the background thread using Task.Run() and then await the Task, to asynchronously wait for it to complete and resume on the UI thread:
private async Task GetAll()
collA = new ObservableCollection(await Task.Run(() => GetA<A>()));
_refreshA = false;
collB = new ObservableCollection(await Task.Run(() => GetB<B>(param)));
_refreshB = false;
collC = new ObservableCollection(await Task.Run(() => GetC<C>()));
_refreshC = false;
Don't know how to build task -- for parent task that calls other tasks