Why does this code work perfectly, outputting the HTML as expected and...
<div class="page home-page custom-container d-flex flex-column">
@await Component.InvokeAsync("PersonalizedProducts")
@await Component.InvokeAsync("RecommendedProducts")
@await Component.InvokeAsync("SuggestedProducts")
@await Component.InvokeAsync("HomePageProducts")
@await Component.InvokeAsync("HomePageNewProducts")
@await Component.InvokeAsync("CategoryFeaturedProducts")
</div>
...this one doesn't work:
<div class="page home-page custom-container d-flex flex-column">
@{
var tasks = new List<Task>();
tasks.Add(Component.InvokeAsync("PersonalizedProducts"));
tasks.Add(Component.InvokeAsync("RecommendedProducts"));
tasks.Add(Component.InvokeAsync("SuggestedProducts"));
tasks.Add(Component.InvokeAsync("HomePageProducts"));
tasks.Add(Component.InvokeAsync("HomePageNewProducts"));
tasks.Add(Component.InvokeAsync("CategoryFeaturedProducts"));
await Task.WhenAll(tasks);
}
</div>
The components mentioned above are 100% independent between themselves and do not share anything but a database, which they do no alter since these are fetch-only components...