-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Real-World Web Development with .NET 10 - Second Edition
By :
When building a desktop or mobile app, multiple tasks (and their underlying threads) can be used to improve responsiveness, because while one thread is busy with the task, another can handle interactions with the user.
Tasks can be useful on the server side too, especially with websites that work with files, or request data from a store or a web service that could take a while to respond. But they are detrimental to complex calculations that are CPU-bound, so leave these to be processed synchronously as normal.
When a request handler performs I/O tasks like database queries, file access, or HTTP calls, use the asynchronous APIs so the thread can return to the pool while the OS completes the I/O task. That increases throughput because the freed thread can run other requests. By contrast, async doesn’t speed up CPU-bound calculations; on servers, keep them synchronous or run them in a separate service...