更新时间:2021-07-09 19:35:50
封面
版权信息
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Chapter 1. Threading Basics
Introduction
Creating a thread in C#
Pausing a thread
Making a thread wait
Aborting a thread
Determining a thread state
Thread priority
Foreground and background threads
Passing parameters to a thread
Locking with a C# lock keyword
Locking with a Monitor construct
Handling exceptions
Chapter 2. Thread Synchronization
Performing basic atomic operations
Using the Mutex construct
Using the SemaphoreSlim construct
Using the AutoResetEvent construct
Using the ManualResetEventSlim construct
Using the CountDownEvent construct
Using the Barrier construct
Using the ReaderWriterLockSlim construct
Using the SpinWait construct
Chapter 3. Using a Thread Pool
Invoking a delegate on a thread pool
Posting an asynchronous operation on a thread pool
A thread pool and the degree of parallelism
Implementing a cancellation option
Using a wait handle and timeout with a thread pool
Using a timer
Using the BackgroundWorker component
Chapter 4. Using the Task Parallel Library
Creating a task
Performing basic operations with a task
Combining tasks
Converting the APM pattern to tasks
Converting the EAP pattern to tasks
Implementing a cancelation option
Handling exceptions in tasks
Running tasks in parallel
Tweaking the execution of tasks with TaskScheduler
Chapter 5. Using C# 6.0
Using the await operator to get asynchronous task results
Using the await operator in a lambda expression
Using the await operator with consequent asynchronous tasks
Using the await operator for the execution of parallel asynchronous tasks
Handling exceptions in asynchronous operations
Avoiding the use of the captured synchronization context
Working around the async void method
Designing a custom awaitable type
Using the dynamic type with await
Chapter 6. Using Concurrent Collections
Using ConcurrentDictionary
Implementing asynchronous processing using ConcurrentQueue
Changing asynchronous processing order with ConcurrentStack
Creating a scalable crawler with ConcurrentBag
Generalizing asynchronous processing with BlockingCollection
Chapter 7. Using PLINQ
Using the Parallel class
Parallelizing a LINQ query
Tweaking the parameters of a PLINQ query
Handling exceptions in a PLINQ query
Managing data partitioning in a PLINQ query
Creating a custom aggregator for a PLINQ query
Chapter 8. Reactive Extensions
Converting a collection to an asynchronous Observable
Writing custom Observable
Using the Subject type family
Creating an Observable object
Using LINQ queries against an observable collection
Creating asynchronous operations with Rx
Chapter 9. Using Asynchronous I/O
Working with files asynchronously
Writing an asynchronous HTTP server and client
Working with a database asynchronously
Calling a WCF service asynchronously
Chapter 10. Parallel Programming Patterns
Implementing Lazy-evaluated shared states
Implementing Parallel Pipeline with BlockingCollection
Implementing Parallel Pipeline with TPL DataFlow
Implementing Map/Reduce with PLINQ
Chapter 11. There's More
Using a timer in a Universal Windows Platform application