Chapter 4. Using the Task Parallel Library
In this chapter, we will dive into a new asynchronous programming paradigm, the Task Parallel Library. You will learn the following recipes:
- Creating a task
- Performing basic operations with a task
- Combining tasks together
- 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
Introduction
In the previous chapters, you learned what a thread is, how to use threads, and why we need a thread pool. Using a thread pool allows us to save operating system resources at the cost of reducing a parallelism degree. We can think of a thread pool as an abstraction layer that ...
Get Multithreading with C# Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.