Chapter 6. Thread Usage
When your site accesses a file or an off-box resource such as the database or a web service, the thread executing the request is blocked while it waits for the resource to respond. You now have a thread doing nothing, while there may be requests waiting for a thread to become available.
You can solve this by using asynchronous methods to access files and off-box resources. Instead of blocking a thread, these methods release the thread when they start waiting, so that it can then be used by another request. When the resource becomes available, a new thread is acquired from the thread pool to continue processing.
This chapter shows how to convert synchronous code that blocks the thread to asynchronous code. Each example will first describe the synchronous version, and then we'll see how to make it asynchronous. Specifically, you will learn:
How to convert the code that accesses web services
How to convert the code that accesses the database, including how to build an asynchronous...