Yeah, doing the multi get well using Tasks is a bit tricky. I’ve been playing with making an extension library to implement a best practice pattern, but it’s not done yet.
See this post on info on how to optimize the process: Bulk Insert In Every Two Minutes - #4 by btburnett3
Also, you can address the exception thrown on await Task.WhenAll(...)
like this:
try
{
await Task.WhenAll(tasks);
}
catch
{
// Exception will be of any type, just ignore
}
foreach (var task in tasks)
{
if (task.IsCompletedSuccessfully)
{
// Do something with task.Result
}
else
{
// Do something with task.Exception
}
}