I've been trying to figure out why the UI was blocking from a ViewModel method, and realized that this part of the code:
await Task.WhenAll(getOutput1(), getOutput2());
was the problem. I managed to unblock the UI by using:
await Task.WhenAll(Task.Run(() => getOutput1()), Task.Run(() => getOutput2()));
getOutput1()
and getOutput2()
are both async
with Task
return types in the ViewModel, and the code is called from the View.
What's the difference with calling Task.WhenAll when I call Task.Run() and just directly supplying the task?