---
title: "Asynchronous Programming in C#"
description: "In this 2-day workshop, experienced C# developers learn threads, tasks, async/await, cancellation and synchronization contexts, and how to avoid deadlocks."
url: https://tn-data.se/courses/asynchronous-programming-in-csharp/
type: workshop
lang: en
alternate: https://tn-data.se/sv/kurser/asynkron-programmering-i-csharp.md
site: https://tn-data.se/
image: https://tn-data.se/_astro/23._Pj5-UyO_Z2rSIhm.webp
---

# Asynchronous Programming in C#

> Learn how threads, tasks and async/await work in .NET, and how to write async code that is correct and fast.

## Workshop facts

- **Duration:** 2 full days or 4 half days
- **Level:** Advanced
- **Language:** English, Swedish

**This two-day workshop is for experienced C# and .NET developers. It covers asynchronous programming from threads, tasks and async/await up to task schedulers and synchronization contexts.**

### What You Will Learn

1. How threads, the thread pool and tasks work underneath async/await.
2. Async/await, cancellation and continuations, through a lot of hands-on coding.
3. How to avoid common problems such as deadlocks, thread starvation and unobserved exceptions.
4. Advanced techniques such as custom task schedulers, synchronization contexts and ValueTasks.

### Why Learn Asynchronous Programming?

Most of the .NET code you work with today is asynchronous. ASP.NET Core, Entity Framework Core, HttpClient and most modern libraries are built around Task, async and await. Calling them is simple, but mistakes such as deadlocks, blocked threads and lost exceptions are common, and they often show up only under load in production. To avoid them, you need to understand what happens underneath.

### How the Workshop Works

There are plenty of hands-on exercises, so you practise each concept as you learn it. Afterwards you know how to use asynchronous code to make your applications more efficient, scalable and responsive.

### Who Is This Workshop For?

Experienced C# developers who want to understand how asynchronous code works and write it correctly in their applications.

### Prerequisites

At least one year of experience as a C# developer, and a good understanding of C#, including generics, lambdas and LINQ. You don't need any experience with parallel or async programming. The workshop is up to date with .NET 10 and C# 14.

![Tore Nestenius presenting at the Øredev conference in Malmö, November 2024.](https://tn-data.se/_astro/Screenshot-2026-01-13-214713.Bo4GFCL5_2kEnKn.webp) ![Tore Nestenius presenting about authentication at the Copenhagen .NET User Group](https://tn-data.se/_astro/IMG_2248-1024x768._CypaLk0_PjcnA.webp)

## Workshop Agenda

During the workshop, we cover the following topics.

### 1\. Introduction, Processes, and Threads

- Synchronous vs. Asynchronous programming
- Processes
- Threads

### 2\. Thread Pool

- The cost of creating threads
- Worker and I/O Threads
- When not to use the thread pool

### 3\. Tasks

- Creating tasks
- Returning data from a task
- Using Tasks or Threads?

### 4\. Waiting For Tasks

- WaitAll vs. WaitAny
- WhenAll vs. WhenAny

### 5\. Error Handling in Asynchronous Code

- Exceptions in threads
- Exceptions in tasks

### 6\. Cancelling Tasks

- Cancellation Token Source
- IsCancellationRequested
- ThrowIfCancellationRequested
- Cancellation Tokens
- Combining Cancellation Tokens

### 7\. Continuations

- ContinueWith
- TaskContinuationOptions

### 8\. Async – Await

- Async methods
- Async state machine
- The await keyword
- Returning data from async methods
- Async all the way
- Async lambdas
- Optimizing async/await
- GetAwaiter().GetResult()
- WaitAsync

### 9\. Task Schedulers

- ThreadPoolTaskScheduler
- Default vs. Current task scheduler
- Creating custom task schedulers
- ExclusiveScheduler vs. ConcurrentScheduler

### 10\. Async Error Handling

- Exceptions in async methods
- Releasing exceptions
- Task Schedulers and the UnobservedTaskException

### 11\. Synchronization Contexts

- SynchronizationContext vs. TaskScheduler
- ThreadPoolTaskScheduler
- DispatcherSynchronizationContext
- WindowsFormsSynchronizationContext

### 12\. ConfigureAwait

- Avoiding deadlocks
- Capturing the synchronization context
- ConfigureAwaitOptions

### 13\. Value Tasks

- Tasks vs ValueTasks
- Optimizing async methods
- Reducing allocations

### Training FAQs

#### Why should I learn asynchronous programming in C#?

Most modern .NET libraries are built around Task, async and await. When you understand async programming, you can build responsive apps, avoid thread starvation and deadlocks, and write code that scales, for web, desktop and services.

#### What topics are covered in this workshop?

Async programming from the ground up: how work runs on threads, how the .NET thread pool behaves, how Task works, and how to write correct, efficient async code with async/await, cancellation and good patterns.

#### Why do you cover threads if we mostly use async/await?

You rarely create threads by hand in day-to-day .NET development, but all async code ends up running on threads. When you understand threads and the thread pool, it is easier to reason about performance, responsiveness and blocking code, and to see why certain async bugs happen.

#### What topics are not covered in this workshop?

To keep the workshop focused, I do not cover locks, concurrent collections, TPL Dataflow, Channels or Pipelines. These concurrency topics would need a workshop of their own.

#### Is this workshop suitable for beginners?

No, this is not a beginner workshop. You should be comfortable with modern C#, including lambdas and LINQ. You don't need experience with async or parallel programming, but it helps if you have seen Task and async/await before.

#### What version of .NET is used?

I use .NET 10 and Visual Studio 2026. What you learn also applies to earlier .NET versions, though some APIs and diagnostics features may differ.

#### What if I’m using an older version like .NET 6–9?

You can still attend. The core async model (Task, async/await, cancellation, continuations) is the same in .NET 6–9. I point out the few places where .NET 10 has newer APIs or better tooling.

#### Is this workshop live or recorded?

It is live and instructor-led, and it is not recorded. I teach it in person or online, usually in Zoom or Teams. You can ask questions throughout and get feedback during the exercises.

#### How much coding is included?

More than half of the workshop is hands-on coding, with exercises in every module. They start at an intermediate level and get harder as you go, so you run into the common pitfalls yourself and learn patterns you can use directly in your own .NET applications.

#### Do I need any special tools?

You need a .NET development environment that can run .NET 10 (Visual Studio 2026 or another .NET IDE). I send setup instructions before the workshop.

#### Will I get the material and example code afterwards?

Yes. You get the slides and exercises as PDF, and the full exercise solutions with completed code, so you can review and practise after the workshop.

#### How up to date is this workshop?

I maintain it all the time. I update the content for new .NET features and practices, and I improve the exercises and material after each delivery, based on feedback from the participants.

#### Do you offer on-site and remote training?

Yes. I offer both on-site (classroom) training and live online sessions.

#### Do you provide training in Swedish and English?

Yes. I can teach in Swedish or English. The material is in English.

#### Do you offer half-day training?

For on-site deliveries, I usually run full days. For remote deliveries, half days or full days can be arranged.

#### Do you do webinars and shorter talks?

Yes. See my [Talks](https://tn-data.se/talks/) page for current options and topics.

#### Can the workshop be customized for our team?

Yes. For private team deliveries, I can adapt the agenda and exercises to your codebase, tech stack and problem areas. [Contact me](https://tn-data.se/contact/) with your goals.

## About the Trainer

My name is [Tore Nestenius](https://tn-data.se/about/). I teach on-site and remotely, both directly for companies and through training companies in Europe. What I bring:

- I have trained developers since 2010 and taught several hundred courses and talks.
- I create, maintain and teach every course myself, and improve it after every delivery.
- I am a Microsoft .NET MVP.
- I co-founded [Edument](https://www.edument.se/), a Swedish training and consulting company, where I was CTO, developer and trainer.
- I work as an [independent senior .NET consultant](https://tn-data.se/consulting/), so I teach from real projects.
- I have worked with .NET and C# since 2002.
- I hold the Azure AZ-204 and AZ-900 certifications.
- I co-founded the [.NET Skåne](https://www.meetup.com/net-skane/) user group.

#### Follow me

Connect with me on [**LinkedIn**](https://www.linkedin.com/in/torenestenius/) to stay updated on my latest blog posts, upcoming presentations, webinars, and more.

![Tore Nestenius presenting at the .NET Skåne user group in Malmö, December 2024 about Rebuilding the Task and ThreadPool Concepts in .NET.](https://tn-data.se/_astro/PXL_20241211_184916722_exported_668_1733943001198-r4pyl9fel5hqcb423h7ln31d7520miga9943x1s5j4.DhpJDhBL_ZA92mn.webp "PXL_20241211_184916722_exported_668_1733943001198") [![Microsoft MVP profile of Tore Nestenius](https://tn-data.se/_astro/MVP_Digital_RGB_31_badge_full_color_blue.BZMWQT9U_ZiBy1A.webp)](https://mvp.microsoft.com/en-US/mvp/profile/5150f7cb-54d8-48d8-a450-46b2b677d634)

To book this workshop or ask about it, see the [contact page](https://tn-data.se/contact/).
