Mastering C# Concurrency

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

Mastering C# Concurrency

Eugene Agafonov, Andrew Koryavchenko

4 customer reviews
Create robust and scalable applications along with responsive UI using concurrency and the multi-threading infrastructure in .NET and C#
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mastering C# Concurrency Book Cover
Mastering C# Concurrency
$ 39.99
$ 28.00
Mastering C# and .NET Framework Book Cover
Mastering C# and .NET Framework
$ 35.99
$ 25.20
Buy 2 for $35.00
Save $40.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

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 4 reviews

Read More Reviews

Recommended for You

C# 6 and .NET Core 1.0: Modern Cross-Platform Development Book Cover
C# 6 and .NET Core 1.0: Modern Cross-Platform Development
$ 39.99
$ 28.00
Multithreading in C# 5.0 Cookbook Book Cover
Multithreading in C# 5.0 Cookbook
$ 29.99
$ 21.00
ASP.NET Core and Angular 2 Book Cover
ASP.NET Core and Angular 2
$ 35.99
$ 25.20
Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Multithreading with C# Cookbook - Second Edition Book Cover
Multithreading with C# Cookbook - Second Edition
$ 39.99
$ 28.00
Mastering C# and .NET Framework Book Cover
Mastering C# and .NET Framework
$ 35.99
$ 25.20