I'm struggling with making my tasks run. I believe they don't start and await never returns, that way my application never runs further. It's meant to process multiple data sets (known at the moment of execution) and therefore I add them using a loop, it looks this way:
foreach(IGrouping<enumType, Item> group in lp)
{
Task<ProcessedItem> t = new Task<ProcessedItem>(
() => ProcessItems(group.ToList(), group.Key));
tasks.Add(t);
}
await Task.WhenAll(tasks);
(...)
And it stops at Task.WhenAll. I think they're not started at all, I have a similar code within another method, but there I pass the function to the task directly:
Task<ReturnType>(Func);
Which I believe causes the difference, I cannot pass it this way here due to parameters. How should I modify my code to make it work? Should I explicitly start each task? Wouldn't that break the await keyword if tasks finishes before the await?