Book Image

Visual Studio 2013 Cookbook

Book Image

Visual Studio 2013 Cookbook

Overview of this book

Table of Contents (17 chapters)
Visual Studio 2013 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Making your code asynchronous


So, you've got yourself an application that might be lacking in the performance department. If you're honest, it's probably horribly slow, and yet when you look at the performance counters on the host machine, it doesn't seem to be doing all that much. The odds are high that your existing code is operating slowly and blocking the execution thread, which prevents other code from executing.

It gets even worse in web applications that come under heavy load. Every request thread that gets blocked is a point where other requests can get queued, and before too long you've got yourself a server that is throwing 503 Service Unavailable errors.

Time to take that synchronous code, stick an "a" on the front of it, and more efficiently take advantage of your production system's hardware. Keep in mind that before you make all of your code asynchronous, you should understand where it blocks and where it doesn't (refer to Chapter 5, Debugging Your .NET Application, for some...