Async in C# 5.0 - Helion
ISBN: 978-14-493-3712-4
stron: 108, Format: ebook
Data wydania: 2012-09-07
Księgarnia: Helion
Cena książki: 38,17 zł (poprzednio: 44,38 zł)
Oszczędzasz: 14% (-6,21 zł)
If you’re writing one of several applications that call for asynchronous programming, this concise hands-on guide shows you how the async feature in C# 5.0 can make the process much simpler. Along with a clear introduction to asynchronous programming, you get an in-depth look at how the async feature works and why you might want to use it in your application.
Written for experienced C# programmers—yet approachable for beginners—this book is packed with code examples that you can extend for your own projects.
- Write your own asynchronous code, and learn how async saves you from this messy chore
- Discover new performance possibilities in ASP.NET web server code
- Explore how async and WinRT work together in Windows 8 applications
- Learn the importance of the await keyword in async methods
- Understand which .NET thread is running your code—and at what points in the program
- Use the Task-based Asynchronous Pattern (TAP) to write asynchronous APIs in .NET
- Take advantage of parallel computing in modern machines
- Measure async code performance by comparing it with alternatives
Osoby które kupowały "Async in C# 5.0", wybierały także:
- Windows Media Center. Domowe centrum rozrywki 66,67 zł, (8,00 zł -88%)
- Ruby on Rails. Ćwiczenia 18,75 zł, (3,00 zł -84%)
- Przywództwo w świecie VUCA. Jak być skutecznym liderem w niepewnym środowisku 58,64 zł, (12,90 zł -78%)
- Scrum. O zwinnym zarządzaniu projektami. Wydanie II rozszerzone 58,64 zł, (12,90 zł -78%)
- Od hierarchii do turkusu, czyli jak zarządzać w XXI wieku 58,64 zł, (12,90 zł -78%)
Spis treści
Async in C# 5.0. Unleash the Power of Async eBook -- spis treści
- Async in C# 5.0
- SPECIAL OFFER: Upgrade this ebook with OReilly
- Preface
- Intended Audience
- How to Read This Book
- Conventions Used in This Book
- Using Code Examples
- Safari Books Online
- How to Contact Us
- Acknowledgments
- 1. Introduction
- Asynchronous Programming
- Whats So Great About Asynchronous Code?
- What Is Async?
- What Async Does
- Async Doesnt Solve Everything
- 2. Why Programs Need to Be Asynchronous
- Desktop User Interface Applications
- An Analogy: The Cafe
- Web Application Server Code
- Another Analogy: The Restaurant Kitchen
- Silverlight, Windows Phone, and Windows 8
- Parallel Code
- An Example
- Desktop User Interface Applications
- 3. Writing Asynchronous Code Manually
- Some Asynchronous Patterns Used in .NET
- The Simplest Asynchronous Pattern
- An Introduction to Task
- The Problem with Manual Asynchrony
- Converting the Example to Use Manual Asynchronous Code
- 4. Writing Async Methods
- Converting the Favicon Example to Async
- Task and await
- Async Method Return Types
- Async, Method Signatures, and Interfaces
- The return Statement in Async Methods
- Async Methods Are Contagious
- Async Anonymous Delegates and Lambdas
- 5. What await Actually Does
- Hibernating and Resuming a Method
- The State of the Method
- Context
- Where await Cant Be Used
- catch and finally Blocks
- lock Blocks
- LINQ Query Expressions
- Unsafe Code
- Exception Capture
- Async Methods Are Synchronous Until Needed
- 6. The Task-Based Asynchronous Pattern
- What the TAP Specifies
- Using Task for Compute-Intensive Operations
- Creating a Puppet Task
- Interacting with Old Asynchronous Patterns
- Cold and Hot Tasks
- Up-Front Work
- 7. Utilities for Async Code
- Delaying for a Period of Time
- Waiting for a Collection of Tasks
- Waiting for Any One Task from a Collection
- Creating Your Own Combinators
- Cancelling Asynchronous Operations
- Returning Progress During an Asynchronous Operation
- 8. Which Thread Runs My Code?
- Before the First await
- During the Asynchronous Operation
- SynchronizationContext in Detail
- await and SynchronizationContext
- The Lifecycle of an Async Operation
- Choosing Not to Use SynchronizationContext
- Interacting with Synchronous Code
- 9. Exceptions in Async Code
- Exceptions in Async Task-Returning Methods
- Unobserved Exceptions
- Exceptions in Async void Methods
- Fire and Forget
- AggregateException and WhenAll
- Throwing Exceptions Synchronously
- finally in Async Methods
- 10. Parallelism Using Async
- await and locks
- Actors
- Using Actors in C#
- Task Parallel Library Dataflow
- 11. Unit Testing Async Code
- The Problem with Unit Testing in Async
- Writing Working Async Tests Manually
- Using Unit Test Framework Support
- 12. Async in ASP.NET Applications
- Advantages of Asynchronous Web Server Code
- Using Async in ASP.NET MVC 4
- Using Async in Older Versions of ASP.NET MVC
- Using Async in ASP.NET Web Forms
- 13. Async in WinRT Applications
- What Is WinRT?
- IAsyncAction and IAsyncOperation<T>
- Cancellation
- Progress
- Providing Asynchronous Methods in a WinRT Component
- 14. The Async Compiler Transformin Depth
- The stub Method
- The State Machine Struct
- The MoveNext Method
- Your Code
- Transforming Returns to Completions
- Get to the Right Place in the Method
- Pausing the Method for the await
- Resuming after the Await
- Completing Synchronously
- Catching Exceptions
- More Complicated Code
- Writing Custom Awaitable Types
- Interacting with the Debugger
- 15. The Performance of Async Code
- Measuring Async Overhead
- Async Versus Blocking for a Long-Running Operation
- Optimizing Async Code for a Long-Running Operation
- Async Versus Manual Asynchronous Code
- Async Versus Blocking Without a Long-Running Operation
- Optimizing Async Code Without a Long-Running Operation
- Async Performance Summary
- About the Author
- SPECIAL OFFER: Upgrade this ebook with OReilly
- Copyright