Mastering C# Concurrency

Create robust and scalable applications along with responsive UI using concurrency and the multi-threading infrastructure in .NET and C#

Mastering C# Concurrency

Mastering
Eugene Agafonov, Andrew Koryavchenko

3 customer reviews
Create robust and scalable applications along with responsive UI using concurrency and the multi-threading infrastructure in .NET and C#
$39.99
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to get that next promotion or to land that dream job. Cancel anytime.

Free Sample

Book Details

ISBN 139781785286650
Paperback284 pages

Book Description

Starting with the traditional approach to concurrency, you will learn how to write multithreaded concurrent programs and compose ways that won't require locking. You will explore the concepts of parallelism granularity, and fine-grained and coarse-grained parallel tasks by choosing a concurrent program structure and parallelizing the workload optimally. You will also learn how to use task parallel library, cancellations, timeouts, and how to handle errors. You will know how to choose the appropriate data structure for a specific parallel algorithm to achieve scalability and performance. Further, you'll learn about server scalability, asynchronous I/O, and thread pools, and write responsive traditional Windows and Windows Store applications.

By the end of the book, you will be able to diagnose and resolve typical problems that could happen in multithreaded applications.

Table of Contents

Chapter 1: Traditional Concurrency
What's the problem?
Using locks
Reader-writer lock
Spin lock
Optimization strategy
Summary
Chapter 2: Lock-Free Concurrency
Memory model and compiler optimizations
The System.Threading.Interlocked class
Interlocked internals
Writing lock-free code
Summary
Chapter 3: Understanding Parallelism Granularity
The number of threads
Using the thread pool
Understanding granularity
Choosing the coarse-grained or fine-grained approach
Summary
Chapter 4: Task Parallel Library in Depth
Task composition
Tasks hierarchy
Awaiting task completion
Task cancellation
Latency and the coarse-grained approach with TPL
Exception handling
Using the Parallel class
Summary
Chapter 5: C# Language Support for Asynchrony
Implementing the downloading of images from Bing
Is the async keyword really needed?
Fire-and-forget tasks
Other useful TPL features
Implementing a custom awaitable type
Summary
Chapter 6: Using Concurrent Data Structures
Standard collections and synchronization primitives
Implementing a cache with ReaderWriterLockSlim
Concurrent collections in .NET
ConcurrentDictionary
ConcurrentBag<T>
ConcurrentQueue<T>
ConcurrentStack<T>
The Producer/Consumer pattern
The Producer/Consumer pattern in .NET 4.0+
Summary
Chapter 7: Leveraging Parallel Patterns
Concurrent idioms
Asynchronous patterns
Concurrent patterns
Summary
Chapter 8: Server-side Asynchrony
Server applications
The OWIN Web API framework
Load testing and scalability
I/O and CPU-bound tasks
Deep dive into asynchronous I/O
Real and fake asynchronous I/O operations
Synchronization context
CPU-bound tasks and queues
Summary
Chapter 9: Concurrency in the User Interface
The importance of asynchrony for UI
UI threads and message loops
Common problems and solutions
How the await keyword works
Performance issues
Summary
Chapter 10: Troubleshooting Parallel Programs
How troubleshooting parallel programs is different
Writing tests
Integration tests
Debugging
Performance measurement and profiling
Summary

What You Will Learn

  • Apply general multithreading concepts to your application’s design
  • Leverage lock-free concurrency and learn about its pros and cons to achieve efficient synchronization between user threads
  • Combine your asynchronous operations with Task Parallel Library
  • Make your code easier with C#’s asynchrony support
  • Use common concurrent collections and programming patterns
  • Write scalable and robust server-side asynchronous code
  • Create fast and responsible client applications
  • Avoid common problems and troubleshoot your multi-threaded and asynchronous applications

Authors

Table of Contents

Chapter 1: Traditional Concurrency
What's the problem?
Using locks
Reader-writer lock
Spin lock
Optimization strategy
Summary
Chapter 2: Lock-Free Concurrency
Memory model and compiler optimizations
The System.Threading.Interlocked class
Interlocked internals
Writing lock-free code
Summary
Chapter 3: Understanding Parallelism Granularity
The number of threads
Using the thread pool
Understanding granularity
Choosing the coarse-grained or fine-grained approach
Summary
Chapter 4: Task Parallel Library in Depth
Task composition
Tasks hierarchy
Awaiting task completion
Task cancellation
Latency and the coarse-grained approach with TPL
Exception handling
Using the Parallel class
Summary
Chapter 5: C# Language Support for Asynchrony
Implementing the downloading of images from Bing
Is the async keyword really needed?
Fire-and-forget tasks
Other useful TPL features
Implementing a custom awaitable type
Summary
Chapter 6: Using Concurrent Data Structures
Standard collections and synchronization primitives
Implementing a cache with ReaderWriterLockSlim
Concurrent collections in .NET
ConcurrentDictionary
ConcurrentBag<T>
ConcurrentQueue<T>
ConcurrentStack<T>
The Producer/Consumer pattern
The Producer/Consumer pattern in .NET 4.0+
Summary
Chapter 7: Leveraging Parallel Patterns
Concurrent idioms
Asynchronous patterns
Concurrent patterns
Summary
Chapter 8: Server-side Asynchrony
Server applications
The OWIN Web API framework
Load testing and scalability
I/O and CPU-bound tasks
Deep dive into asynchronous I/O
Real and fake asynchronous I/O operations
Synchronization context
CPU-bound tasks and queues
Summary
Chapter 9: Concurrency in the User Interface
The importance of asynchrony for UI
UI threads and message loops
Common problems and solutions
How the await keyword works
Performance issues
Summary
Chapter 10: Troubleshooting Parallel Programs
How troubleshooting parallel programs is different
Writing tests
Integration tests
Debugging
Performance measurement and profiling
Summary

Book Details

ISBN 139781785286650
Paperback284 pages
Read More
From 3 reviews

Read More Reviews