万本电子书0元读

万本电子书0元读

顶部广告

Mastering C# Concurrency电子书

售       价:¥

15人正在读 | 0人评论 9.8

作       者:Eugene Agafonov

出  版  社:Packt Publishing

出版时间:2015-10-28

字       数:83.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Create robust and scalable applications along with responsive UI using concurrency and the multi-threading infrastructure in .NET and C#About This BookLearn to combine your asynchronous operations with Task Parallel LibraryMaster C#’s asynchronous infrastructure and use asynchronous APIs effectively to achieve optimal responsiveness of the applicationAn easy-to-follow, example-based guide that helps you to build scalable applications using concurrency in C# Who This Book Is For If you are a C# developer who wants to develop modern applications in C# and wants to overcome problems by using asynchronous APIs and standard patterns, then this book is ideal for you. Reasonable development knowledge, an understanding of core elements and applications related to the .Net platform, and also the fundamentals of concurrency is assumed.What You Will LearnApply general multithreading concepts to your application’s designLeverage lock-free concurrency and learn about its pros and cons to achieve efficient synchronization between user threadsCombine your asynchronous operations with Task Parallel LibraryMake your code easier with C#’s asynchrony supportUse common concurrent collections and programming patternsWrite scalable and robust server-side asynchronous codeCreate fast and responsible client applicationsAvoid common problems and troubleshoot your multi-threaded and asynchronous applications In Detail 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.Style and approach An easy-to-follow, example-based guide that will walk you through the core principles of concurrency and multithreading using C#.
目录展开

Mastering C# Concurrency

Table of Contents

Mastering C# Concurrency

Credits

About the Authors

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Instant updates on new Packt books

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Traditional Concurrency

What's the problem?

Using locks

Lock statement

Monitor class

Reader-writer lock

Spin lock

Thread.SpinWait

System.Threading.SpinWait

System.Threading.SpinLock

Optimization strategy

Lock localization

Shared data minimization

Summary

2. Lock-Free Concurrency

Memory model and compiler optimizations

The System.Threading.Interlocked class

Interlocked internals

Writing lock-free code

The ABA problem

The lock-free stack

The lock-free queue

Summary

3. Understanding Parallelism Granularity

The number of threads

Using the thread pool

Understanding granularity

Choosing the coarse-grained or fine-grained approach

Summary

4. Task Parallel Library in Depth

Task composition

Tasks hierarchy

Awaiting task completion

Task cancellation

Checking a flag

Throwing an exception

Using OS wait objects with WaitHandle

Cancellation using callbacks

Latency and the coarse-grained approach with TPL

Exception handling

Using the Parallel class

Parallel.Invoke

Parallel.For and Parallel.Foreach

Understanding the task scheduler

Summary

5. C# Language Support for Asynchrony

Implementing the downloading of images from Bing

Creating a simple synchronous solution

Creating a parallel solution with Task Parallel Library

Enhancing the code with C# 5.0 built-in support for asynchrony

Simulating C# asynchronous infrastructure with iterators

Is the async keyword really needed?

Fire-and-forget tasks

Other useful TPL features

Task.Delay

Task.Yield

Implementing a custom awaitable type

Summary

6. Using Concurrent Data Structures

Standard collections and synchronization primitives

Implementing a cache with ReaderWriterLockSlim

Concurrent collections in .NET

ConcurrentDictionary

Using Lazy<T>

Implementation details

Lock-free operations

Fine-grained lock operations

Exclusive lock operations

Using the implementation details in practice

ConcurrentBag<T>

ConcurrentBag in practice

ConcurrentQueue<T>

ConcurrentStack<T>

The Producer/Consumer pattern

Custom Producer/Consumer pattern implementation

The Producer/Consumer pattern in .NET 4.0+

Summary

7. Leveraging Parallel Patterns

Concurrent idioms

Process Tasks in Completion Order

Limiting the parallelism degree

Setting a task timeout

Asynchronous patterns

Asynchronous Programming Model

Event-based Asynchronous Pattern

Task-based Asynchronous Pattern

Concurrent patterns

Parallel pipelines

Summary

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

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

Execution and synchronization contexts

Performance issues

Summary

10. Troubleshooting Parallel Programs

How troubleshooting parallel programs is different

Heisenbugs

Writing tests

Load tests

Unit tests

Integration tests

Debugging

Just my code setting

Call stack window

Threads window

Tasks window

Parallel stacks window

Performance measurement and profiling

The Concurrency Visualizer

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部