万本电子书0元读

万本电子书0元读

顶部广告

Multithreading with C# Cookbook - Second Edition电子书

售       价:¥

2人正在读 | 0人评论 9.8

作       者:Eugene Agafonov

出  版  社:Packt Publishing

出版时间:2016-04-01

字       数:153.2万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Over 70 recipes to get you writing powerful and efficient multithreaded, asynchronous, and parallel programs in C# 6.0 About This Book Rewritten and updated to take advantage of the latest C# 6 features Learn about multithreaded, asynchronous, and parallel programming through hands-on, code-first examples Use these recipes to build fast, scalable, and reliable applications in C# Who This Book Is For This book is aimed at those who are new to multithreaded programming, and who are looking for a quick and easy way to get started. It is assumed that you have some experience in C# and .NET already, and you should also be familiar with basic computer science terminology and basic algorithms and data structures. What You Will Learn Use C# 6.0 asynchronous language features Work with raw threads, synchronize threads, and coordinate their work Develop your own asynchronous API with Task Parallel Library Work effectively with a thread pool Scale up your server application with I/O threads Parallelize your LINQ queries with PLINQ Use common concurrent collections Apply different parallel programming patterns Use Reactive Extensions to run asynchronous operations and manage their options In Detail Multi-core processors are synonymous with computing speed and power in today’s world, which is why multithreading has become a key concern for C# developers. Multithreaded code helps you create effective, scalable, and responsive applications. This is an easy-to-follow guide that will show you difficult programming problems in context. You will learn how to solve them with practical, hands-on, recipes. With these recipes, you’ll be able to start creating your own scalable and reliable multithreaded applications. Starting from learning what a thread is, we guide you through the basics and then move on to more advanced concepts such as task parallel libraries, C# asynchronous functions, and much more. Rewritten to the latest C# specification, C# 6, and updated with new and modern recipes to help you make the most of the hardware you have available, this book will help you push the boundaries of what you thought possible in C#. Style and approach This is an easy-to-follow guide full of hands-on examples of real-world multithreading tasks. Each topic is explained and placed in context, and for the more inquisitive, there are also more in-depth details of the concepts used.
目录展开

Multithreading with C# Cookbook Second Edition

Table of Contents

Multithreading with C# Cookbook Second Edition

Credits

About the Author

About the Reviewers

www.PacktPub.com

eBooks, discount offers, and more

Why Subscribe?

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. Threading Basics

Introduction

Creating a thread in C#

Getting ready

How to do it...

How it works...

Pausing a thread

Getting ready

How to do it...

How it works...

Making a thread wait

Getting ready

How to do it...

How it works...

Aborting a thread

Getting ready

How to do it...

How it works...

Determining a thread state

Getting ready

How to do it...

How it works...

Thread priority

Getting ready

How to do it...

How it works...

Foreground and background threads

Getting ready

How to do it...

How it works...

Passing parameters to a thread

Getting ready

How to do it...

How it works...

There's more…

Locking with a C# lock keyword

Getting ready

How to do it...

How it works...

Locking with a Monitor construct

Getting ready

How to do it...

How it works...

Handling exceptions

Getting ready

How to do it...

How it works...

2. Thread Synchronization

Introduction

Performing basic atomic operations

Getting ready

How to do it...

How it works...

Using the Mutex construct

Getting ready

How to do it...

How it works...

Using the SemaphoreSlim construct

Getting ready

How to do it...

How it works...

There's more…

Using the AutoResetEvent construct

Getting ready

How to do it...

How it works...

Using the ManualResetEventSlim construct

Getting ready

How to do it...

How it works...

There's more…

Using the CountDownEvent construct

Getting ready

How to do it...

How it works...

Using the Barrier construct

Getting ready

How to do it...

How it works...

Using the ReaderWriterLockSlim construct

Getting ready

How to do it...

How it works...

Using the SpinWait construct

Getting ready

How to do it...

How it works...

3. Using a Thread Pool

Introduction

Invoking a delegate on a thread pool

Getting ready

How to do it...

How it works...

Posting an asynchronous operation on a thread pool

Getting ready

How to do it...

How it works...

A thread pool and the degree of parallelism

Getting ready

How to do it...

How it works...

Implementing a cancellation option

Getting ready

How to do it...

How it works...

Using a wait handle and timeout with a thread pool

Getting ready

How to do it...

How it works...

There's more…

Using a timer

Getting ready

How to do it...

How it works...

Using the BackgroundWorker component

Getting ready

How to do it...

How it works...

4. Using the Task Parallel Library

Introduction

Creating a task

Getting ready

How to do it...

How it works...

Performing basic operations with a task

Getting ready

How to do it...

How it works...

Combining tasks

Getting ready

How to do it...

How it works...

Converting the APM pattern to tasks

Getting ready

How to do it...

How it works...

Converting the EAP pattern to tasks

Getting ready

How to do it...

How it works...

Implementing a cancelation option

Getting ready

How to do it...

How it works...

Handling exceptions in tasks

Getting ready

How to do it...

How it works...

There's more…

Running tasks in parallel

Getting ready

How to do it...

How it works...

Tweaking the execution of tasks with TaskScheduler

Getting ready

How to do it...

How it works...

5. Using C# 6.0

Introduction

Using the await operator to get asynchronous task results

Getting ready

How to do it...

How it works...

Using the await operator in a lambda expression

Getting ready

How to do it...

How it works...

Using the await operator with consequent asynchronous tasks

Getting ready

How to do it...

How it works...

Using the await operator for the execution of parallel asynchronous tasks

Getting ready

How to do it...

How it works...

Handling exceptions in asynchronous operations

Getting ready

How to do it...

How it works...

Avoiding the use of the captured synchronization context

Getting ready

How to do it...

How it works...

Working around the async void method

Getting ready

How to do it...

How it works...

Designing a custom awaitable type

Getting ready

How to do it...

How it works...

Using the dynamic type with await

Getting ready

How to do it...

How it works...

6. Using Concurrent Collections

Introduction

Using ConcurrentDictionary

Getting ready

How to do it...

How it works...

Implementing asynchronous processing using ConcurrentQueue

Getting ready

How to do it...

How it works...

Changing asynchronous processing order with ConcurrentStack

Getting ready

How to do it...

How it works...

Creating a scalable crawler with ConcurrentBag

Getting ready

How to do it...

How it works...

Generalizing asynchronous processing with BlockingCollection

Getting ready

How to do it...

How it works...

7. Using PLINQ

Introduction

Using the Parallel class

Getting ready

How to do it...

How it works...

Parallelizing a LINQ query

Getting ready

How to do it...

How it works...

Tweaking the parameters of a PLINQ query

Getting ready

How to do it...

How it works...

Handling exceptions in a PLINQ query

Getting ready

How to do it...

How it works...

Managing data partitioning in a PLINQ query

Getting ready

How to do it...

How it works...

Creating a custom aggregator for a PLINQ query

Getting ready

How to do it...

How it works...

8. Reactive Extensions

Introduction

Converting a collection to an asynchronous Observable

Getting ready

How to do it...

How it works...

Writing custom Observable

Getting ready

How to do it...

How it works...

Using the Subject type family

Getting ready

How to do it...

How it works...

Creating an Observable object

Getting ready

How to do it...

How it works...

Using LINQ queries against an observable collection

Getting ready

How to do it...

How it works...

Creating asynchronous operations with Rx

Getting ready

How to do it...

How it works...

9. Using Asynchronous I/O

Introduction

Working with files asynchronously

Getting ready

How to do it...

How it works...

Writing an asynchronous HTTP server and client

Getting ready

How to do it...

How it works...

Working with a database asynchronously

Getting ready

How to do it...

How it works...

Calling a WCF service asynchronously

Getting ready

How to do it...

How it works...

10. Parallel Programming Patterns

Introduction

Implementing Lazy-evaluated shared states

Getting ready

How to do it...

How it works...

Implementing Parallel Pipeline with BlockingCollection

Getting ready

How to do it...

How it works...

Implementing Parallel Pipeline with TPL DataFlow

Getting ready

How to do it...

How it works...

Implementing Map/Reduce with PLINQ

Getting ready

How to do it...

How it works...

11. There's More

Introduction

Using a timer in a Universal Windows Platform application

Getting ready

How to do it...

How it works...

Using WinRT from usual applications

Getting ready

How to do it...

How it works...

Using BackgroundTask in Universal Windows Platform applications

Getting ready

How to do it...

How it works...

Running a .NET Core application on OS X

Getting ready

How to do it...

How it works...

Running a .NET Core application on Ubuntu Linux

Getting ready

How to do it...

How it works...

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部