Book description
If you’re one of many developers still uncertain about concurrent and multithreaded development, this practical cookbook will change your mind. With more than 85 code-rich recipes in this updated second edition, author Stephen Cleary demonstrates parallel processing and asynchronous programming techniques using libraries and language features in .NET and C# 8.0.
Concurrency is now more common in responsive and scalable application development, but it’s still extremely difficult to code. The detailed solutions in this cookbook show you how modern tools raise the level of abstraction, making concurrency much easier than before. Complete with ready-to-use code and discussions about how and why solutions work, these recipes help you:
- Get up to speed on concurrency and async and parallel programming
- Use async and await for asynchronous operations
- Enhance your code with asynchronous streams
- Explore parallel programming with .NET’s Task Parallel Library
- Create dataflow pipelines with .NET’s TPL Dataflow library
- Understand the capabilities that System.Reactive builds on top of LINQ
- Utilize threadsafe and immutable collections
- Learn how to conduct unit testing with concurrent code
- Make the thread pool work for you
- Enable clean, cooperative cancellation
- Examine scenarios for combining concurrent approaches
- Dive into asynchronous-friendly object-oriented programming
- Recognize and write adapters for code using older asynchronous styles
Publisher resources
Table of contents
- Preface
- Concurrency: An Overview
-
Async Basics
- 2.1. Pausing for a Period of Time
- 2.2. Returning Completed Tasks
- 2.3. Reporting Progress
- 2.4. Waiting for a Set of Tasks to Complete
- 2.5. Waiting for Any Task to Complete
- 2.6. Processing Tasks as They Complete
- 2.7. Avoiding Context for Continuations
- 2.8. Handling Exceptions from async Task Methods
- 2.9. Handling Exceptions from async void Methods
- 2.10. Creating a ValueTask
- 2.11. Consuming a ValueTask
-
Asynchronous Streams
- Asynchronous Streams and Task<T>
- Asynchronous Streams and IEnumerable<T>
- Asynchronous Streams and Task<IEnumerable<T>>
- Asynchronous Streams and IObservable<T>
- Summary
- 3.1. Creating Asynchronous Streams
- 3.2. Consuming Asynchronous Streams
- 3.3. Using LINQ with Asynchronous Streams
- 3.4. Asynchronous Streams and Cancellation
- Parallel Basics
- Dataflow Basics
- System.Reactive Basics
- Testing
-
Interop
- 8.1. Async Wrappers for “Async” Methods with “Completed” Events
- 8.2. Async Wrappers for “Begin/End” Methods
- 8.3. Async Wrappers for Anything
- 8.4. Async Wrappers for Parallel Code
- 8.5. Async Wrappers for System.Reactive Observables
- 8.6. System.Reactive Observable Wrappers for async Code
- 8.7. Asynchronous Streams and Dataflow Meshes
- 8.8. System.Reactive Observables and Dataflow Meshes
- 8.9. Converting System.Reactive Observables to Asynchronous Streams
-
Collections
- 9.1. Immutable Stacks and Queues
- 9.2. Immutable Lists
- 9.3. Immutable Sets
- 9.4. Immutable Dictionaries
- 9.5. Threadsafe Dictionaries
- 9.6. Blocking Queues
- 9.7. Blocking Stacks and Bags
- 9.8. Asynchronous Queues
- 9.9. Throttling Queues
- 9.10. Sampling Queues
- 9.11. Asynchronous Stacks and Bags
- 9.12. Blocking/Asynchronous Queues
-
Cancellation
- 10.1. Issuing Cancellation Requests
- 10.2. Responding to Cancellation Requests by Polling
- 10.3. Canceling Due to Timeouts
- 10.4. Canceling async Code
- 10.5. Canceling Parallel Code
- 10.6. Canceling System.Reactive Code
- 10.7. Canceling Dataflow Meshes
- 10.8. Injecting Cancellation Requests
- 10.9. Interop with Other Cancellation Systems
- Functional-Friendly OOP
- Synchronization
- Scheduling
- Scenarios
- Legacy Platform Support
- Recognizing and Interpreting Asynchronous Patterns
- Index
Product information
- Title: Concurrency in C# Cookbook, 2nd Edition
- Author(s):
- Release date: August 2019
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781492054504
You might also like
book
Concurrency in C# Cookbook
If you're one of the many developers uncertain about concurrent and multithreaded development, this practical cookbook …
book
Concurrency in .NET
Concurrency in .NET teaches you how to build concurrent and scalable programs in .NET using the …
book
High-Performance Programming in C# and .NET
Enhance your applications' performance using best practices for benchmarking, application profiling, asynchronous programming, designing responsive UIs, …
book
C# 10 and .NET 6 – Modern Cross-Platform Development - Sixth Edition
Publisher’s Note: Microsoft will stop supporting .NET 6 from November 2024. The newer 8th edition of …