Concurrency in C# Cookbook

Book description

If you're one of the many developers uncertain about concurrent and multithreaded development, this practical cookbook will change your mind. With more than 75 code-rich recipes, author Stephen Cleary demonstrates parallel processing and asynchronous programming techniques, using libraries and language features in .NET 4.5 and C# 5.0.

Publisher resources

View/Submit Errata

Table of contents

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

Product information

  • Title: Concurrency in C# Cookbook
  • Author(s):
  • Release date: June 2014
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449367565