Chapter 13
Asynchronous Programming
WHAT’S IN THIS CHAPTER?
- Why asynchronous programming is important
- Asynchronous patterns
- Foundations of the async and await keywords
- Creating and using asynchronous methods
- Error handling with asynchronous methods
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at http://www.wrox.com/remtitle.cgi?isbn=1118314425 on the Download Code tab. The code for this chapter is divided into the following major examples:
- Async Patterns
- Foundations
- Error Handling
WHY ASYNCHRONOUS PROGRAMMING IS IMPORTANT
The most important change of C# 5 is the advances provided with asynchronous programming. C# 5 adds only two new keywords: async and await. These two keywords are the main focus of this chapter.
With asynchronous programming a method is called that runs in the background (typically with the help of a thread or task), and the calling thread is not blocked.
In this chapter, you can read about different patterns on asynchronous programming such as the asynchronous pattern, the event-based asynchronous pattern, and the new task-based asynchronous pattern (TAP). TAP makes use of the async and await keywords. Comparing these patterns you can see the real advantage of the new style of asynchronous programming.
After discussing the different patterns, you will see the foundation of asynchronous programming by creating tasks and invoking asynchronous methods. You’ll learn about what’s behind the scenes with continuation ...
Get Professional C# 2012 and .NET 4.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.