Concurrency in C# Cookbook: Asynchronous, Parallel, and Multithreaded Programming

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Concurrency is essential for creating fast apps and optimized systems software today. With this cookbook, you will find recipes for writing asynchronous, parallel, and reactive code in C# that enables your app or program to engage in more than one process at a time. Presented in O’Reilly’s popular problem-solution-discussion cookbook format, this guide provides ready-to-use code, along with an explanation of why and how the solution works.

Author(s): Stephen Cleary
Publisher: O'Reilly Media
Year: 2014

Language: English
Pages: 200

Copyright
Table of Contents
Preface
Who Should Read This Book
Why I Wrote This Book
Navigating This Book
Online Resources
Conventions Used in This Book
Safari® Books Online
How to Contact Us
Acknowledgments
Chapter 1. Concurrency: An Overview
1.1. Introduction to Concurrency
1.2. Introduction to Asynchronous Programming
1.3. Introduction to Parallel Programming
1.4. Introduction to Reactive Programming (Rx)
1.5. Introduction to Dataflows
1.6. Introduction to Multithreaded Programming
1.7. Collections for Concurrent Applications
1.8. Modern Design
1.9. Summary of Key Technologies
Chapter 2. Async Basics
2.1. Pausing for a Period of Time
Problem
Solution
Discussion
See Also
2.2. Returning Completed Tasks
Problem
Solution
Discussion
See Also
2.3. Reporting Progress
Problem
Solution
Discussion
See Also
2.4. Waiting for a Set of Tasks to Complete
Problem
Solution
Discussion
See Also
2.5. Waiting for Any Task to Complete
Problem
Solution
Discussion
See Also
2.6. Processing Tasks as They Complete
Problem
Solution
Discussion
See Also
2.7. Avoiding Context for Continuations
Problem
Solution
Discussion
See Also
2.8. Handling Exceptions from async Task Methods
Problem
Solution
Discussion
See Also
2.9. Handling Exceptions from async Void Methods
Problem
Solution
Discussion
See Also
Chapter 3. Parallel Basics
3.1. Parallel Processing of Data
Problem
Solution
Discussion
See Also
3.2. Parallel Aggregation
Problem
Solution
Discussion
See Also
3.3. Parallel Invocation
Problem
Solution
Discussion
See Also
3.4. Dynamic Parallelism
Problem
Solution
Discussion
See Also
3.5. Parallel LINQ
Problem
Solution
Discussion
See Also
Chapter 4. Dataflow Basics
4.1. Linking Blocks
Problem
Solution
Discussion
See Also
4.2. Propagating Errors
Problem
Solution
Discussion
See Also
4.3. Unlinking Blocks
Problem
Solution
Discussion
See Also
4.4. Throttling Blocks
Problem
Solution
Discussion
See Also
4.5. Parallel Processing with Dataflow Blocks
Problem
Solution
Discussion
See Also
4.6. Creating Custom Blocks
Problem
Solution
Discussion
See Also
Chapter 5. Rx Basics
5.1. Converting .NET Events
Problem
Solution
Discussion
See Also
5.2. Sending Notifications to a Context
Problem
Solution
Discussion
See Also
5.3. Grouping Event Data with Windows and Buffers
Problem
Solution
Discussion
See Also
5.4. Taming Event Streams with Throttling and Sampling
Problem
Solution
Discussion
See Also
5.5. Timeouts
Problem
Solution
Discussion
See Also
Chapter 6. Testing
6.1. Unit Testing async Methods
Problem
Solution
Discussion
See Also
6.2. Unit Testing async Methods Expected to Fail
Problem
Solution
Discussion
See Also
6.3. Unit Testing async void Methods
Problem
Solution
Discussion
See Also
6.4. Unit Testing Dataflow Meshes
Problem
Solution
Discussion
See Also
6.5. Unit Testing Rx Observables
Problem
Solution
Discussion
See Also
6.6. Unit Testing Rx Observables with Faked Scheduling
Problem
Solution
Discussion
See Also
Chapter 7. Interop
7.1. Async Wrappers for “Async” Methods with “Completed” Events
Problem
Solution
Discussion
See Also
7.2. Async Wrappers for “Begin/End” methods
Problem
Solution
Discussion
See Also
7.3. Async Wrappers for Anything
Problem
Solution
Discussion
See Also
7.4. Async Wrappers for Parallel Code
Problem
Solution
Discussion
See Also
7.5. Async Wrappers for Rx Observables
Problem
Solution
Discussion
See Also
7.6. Rx Observable Wrappers for async Code
Problem
Solution
Discussion
See Also
7.7. Rx Observables and Dataflow Meshes
Problem
Solution
Discussion
See Also
Chapter 8. Collections
8.1. Immutable Stacks and Queues
Problem
Solution
Discussion
See Also
8.2. Immutable Lists
Problem
Solution
Discussion
See Also
8.3. Immutable Sets
Problem
Solution
Discussion
See Also
8.4. Immutable Dictionaries
Problem
Solution
Discussion
See Also
8.5. Threadsafe Dictionaries
Problem
Solution
Discussion
See Also
8.6. Blocking Queues
Problem
Solution
Discussion
See Also
8.7. Blocking Stacks and Bags
Problem
Solution
Discussion
See Also
8.8. Asynchronous Queues
Problem
Solution
Discussion
See Also
8.9. Asynchronous Stacks and Bags
Problem
Solution
Discussion
See Also
8.10. Blocking/Asynchronous Queues
Problem
Solution
Discussion
See Also
Chapter 9. Cancellation
9.1. Issuing Cancellation Requests
Problem
Solution
Discussion
See Also
9.2. Responding to Cancellation Requests by Polling
Problem
Solution
Discussion
See Also
9.3. Canceling Due to Timeouts
Problem
Solution
Discussion
See Also
9.4. Canceling async Code
Problem
Solution
Discussion
See Also
9.5. Canceling Parallel Code
Problem
Solution
Discussion
See Also
9.6. Canceling Reactive Code
Problem
Solution
Discussion
See Also
9.7. Canceling Dataflow Meshes
Problem
Solution
Discussion
See Also
9.8. Injecting Cancellation Requests
Problem
Solution
Discussion
See Also
9.9. Interop with Other Cancellation Systems
Problem
Solution
Discussion
See Also
Chapter 10. Functional-Friendly OOP
10.1. Async Interfaces and Inheritance
Problem
Solution
Discussion
See Also
10.2. Async Construction: Factories
Problem
Solution
Discussion
See Also
10.3. Async Construction: The Asynchronous Initialization Pattern
Problem
Solution
Discussion
See Also
10.4. Async Properties
Problem
Solution
Discussion
See Also
10.5. Async Events
Problem
Solution
Discussion
See Also
10.6. Async Disposal
Problem
Solution
Discussion
See Also
Chapter 11. Synchronization
11.1. Blocking Locks
Problem
Solution
Discussion
See Also
11.2. Async Locks
Problem
Solution
Discussion
See Also
11.3. Blocking Signals
Problem
Solution
Discussion
See Also
11.4. Async Signals
Problem
Solution
Discussion
See Also
11.5. Throttling
Problem
Solution
Discussion
See Also
Chapter 12. Scheduling
12.1. Scheduling Work to the Thread Pool
Problem
Solution
Discussion
See Also
12.2. Executing Code with a Task Scheduler
Problem
Solution
Discussion
See Also
12.3. Scheduling Parallel Code
Problem
Solution
Discussion
See Also
12.4. Dataflow Synchronization Using Schedulers
Problem
Solution
Discussion
See Also
Chapter 13. Scenarios
13.1. Initializing Shared Resources
Problem
Solution
Discussion
See Also
13.2. Rx Deferred Evaluation
Problem
Solution
Discussion
See Also
13.3. Asynchronous Data Binding
Problem
Solution
Discussion
See Also
13.4. Implicit State
Problem
Solution
Discussion
See Also
Index
About the Author