2 ms·
I would make the argument it does not matter what the intention is, in practice people await CPU bound tasks all the time. In fact, here is what the offical do
by the_mitsuhiko 2y ago
I would make the argument it does not matter what the intention is, in practice people await CPU bound tasks all the time. In fact, here is what the offical docs[1] say:
> You could also have CPU-bound code, such as performing an expensive calculation, which is also a good scenario for writing async code.
[1]: https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-scenarios https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous...
- coldtea 2y ago>You could also have CPU-bound code, such as performing an expensive calculation, which is also a good scenario for writing async code. That's a scenario for a different reason though (to allow sharing the cpu between chunks of the calculation, e.g. to not freeze UI in JS). In that case you might want to async on CPU-bound code. But regarding maximizing utilization, you want async to take more advantage of a core's CPU when you got tasks waiting for IO, and threads to leverage more CPU cores when doing CPU bound tasks.