Have you ever been building a .NET application and run into a frozen UI, a sluggish website, disappointing throughput in background jobs, or lingering confusion around async/await, Task.Run, ConfigureAwait(false), cancellation, and exception handling? This book was written to address exactly those problems.
This is a practical technical book that takes you from foundational concepts to real-world applications, helping you systematically master asynchronous programming in .NET 10. Throughout the book, you will build a clear understanding of threads, Task, async/await, cancellation and timeouts, synchronization primitives, parallel processing, asynchronous data streams, asynchronous resource management, and more advanced topics such as TaskCompletionSource, ValueTask, ExecutionContext, TaskScheduler, and API design.
This book does more than show you the syntax. It also emphasizes the thinking behind it and the judgment needed in practice. You will learn when to use asynchrony, when to use parallelism, how to avoid common pitfalls such as sync-over-async, deadlocks, and thread pool starvation, and how to write modern .NET code that balances correctness, readability, and performance.
Inside the book, you will learn how to:
- Build a clear mental model for threads, concurrency, parallelism, and asynchrony
- Use
async/await,Task.WhenAll, cancellation, timeouts, and exception handling with confidence - Understand synchronization primitives, thread safety, immutable design, and parallel processing
- Master
IAsyncEnumerable<T>,await foreach,Channel, andIAsyncDisposable - Dive into
TaskCompletionSource,ValueTask,Task.Yield,ExecutionContext, andTaskScheduler - Learn the design principles behind modern asynchronous APIs in .NET
- Apply these ideas in real scenarios such as ASP.NET Core, WinForms, and WPF
Whether you are a .NET developer looking to strengthen your async/await fundamentals, an experienced engineer who wants a deeper understanding of the underlying machinery, or someone who wants to build applications that are more stable, more responsive, and more scalable, this book will serve as a complete guide to modern asynchronous programming in .NET.
Book outline
- Chapter 1: Understanding threads and asynchrony
- Chapter 2: Threads and tasks in .NET
- Chapter 3:
asyncandawait - Chapter 4: Exception handling and cancellation
- Chapter 5: Thread synchronization and classic problems
- Chapter 6: Thread safety and immutable collections
- Chapter 7: Parallel processing and PLINQ
- Chapter 8: Asynchronous streams and resource management
- Chapter 9: Advanced Task programming
- Chapter 10: Practical scenarios and best practices
- Chapter 11: Guidelines for designing asynchronous APIs
Target readers
This book is for developers who already have some experience with C# or another programming language and want to deepen their understanding of asynchronous programming in .NET. It is especially suitable for:
- Readers who have heard of or used
async/awaitbut do not yet fully grasp how it works under the hood or what its best practices are. - Readers who want to gain clarity on common topics such as
Task.Run,ConfigureAwait(false), cancellation, timeouts, and exception handling. - .NET engineers who want to move from “I can use the syntax” to “I can make sound design decisions.”
- Developers who want to build applications that are smoother, more stable, and more scalable.
What this book offers
This book uses .NET 10 as its primary platform and explains each topic with practices that align as closely as possible with modern .NET development.
To help you learn more effectively, the book is organized around the following principles:
- Understanding first: Build the essential concepts first, then move on to syntax, APIs, and implementation details.
- Practice-oriented: The book does not just explain how to use an API. It also discusses where it fits, common pitfalls, and best practices.
- Diagrams and analogies: Visuals and concrete analogies help make abstract execution flows and design ideas easier to understand.
- Links to sample code: The examples in this book are published on GitHub, with links provided where appropriate.
Tools used in this book
To follow along with the examples in this book, you will need:
- .NET 10 SDK or later
- Development tools: Visual Studio 2026, Visual Studio Code, Rider, or another editor or IDE that supports .NET
Sample code
The sample code for this book is available on GitHub:
讀者留言