© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
31 replies
D.Mentia

❔ Task.WhenAll for Tests, and other async questions

In xUnit, there is no support for testing async or in parallel within the same collection, where a collection is basically tests that share a single startup and teardown
So I extended some xUnit classes, found where the tests are ran, and instead of awaiting each one in a loop, I start them all and then Task.WhenAll. This makes the tests really fast, and when they pass, verifies there are no concurrency issues

Why would this be a bad idea? I assume there must be a reason they did not do this by default

And, would this be considered Parallel? I always thought async and Parallel are different, even opposite things, but if not awaiting them immediately, then it is parallel, isn't it?



And lastly, should I do some sort of batching, or degrees of parallelism, when doing a large number of Task.WhenAll (in general)? Or is it just going to handle that performantly on its own?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Task.WhenAll does not work without Task.Run inside
C#CC# / help
4y ago
get value from parallel for loop using Task.WhenAll
C#CC# / help
4y ago
Async Task Help
C#CC# / help
2y ago