Grzegorz Lang
Asynchronicity and multithreading in C#
#1about 3 minutes
Understanding multithreading for CPU-intensive work
Multithreading allows CPU-intensive work to run in the background, but creating too many logical threads leads to expensive context switching.
#2about 3 minutes
Using the ThreadPool and Task abstraction
The ThreadPool manages threads for you, and the Task class provides a powerful abstraction for queuing work and retrieving results without blocking.
#3about 2 minutes
Creating and continuing tasks without blocking
Use Task.Run to create and start a hot task in one step, and use the ContinueWith method to process results without blocking the main thread.
#4about 1 minute
Implementing graceful cancellation with CancellationToken
A CancellationToken signals that an operation should be stopped, which can be handled by checking IsCancellationRequested or calling ThrowIfCancellationRequested.
#5about 2 minutes
How SynchronizationContext manages execution environments
SynchronizationContext is an abstraction for an environment, like a UI thread, allowing you to post work back to a specific context from a background thread.
#6about 2 minutes
The role of the TaskScheduler in C#
The TaskScheduler works with the SynchronizationContext to determine where a task's continuation should be executed, such as on the ThreadPool or a specific UI thread.
#7about 4 minutes
Introduction to asynchronicity with async and await
The async and await keywords simplify asynchronous programming for I/O-bound operations by allowing threads to be released instead of blocked while waiting.
#8about 1 minute
Running operations concurrently with Task.WhenAll
Start multiple asynchronous operations without awaiting them immediately and then use Task.WhenAll to wait for all of them to complete concurrently.
#9about 2 minutes
Choosing the right async return type
Avoid using async void, and consider using the allocation-free ValueTask struct instead of Task for performance-critical hot paths, but be aware of its usage limitations.
#10about 1 minute
Using ConfigureAwait to control context capturing
Use ConfigureAwait(false) in library code to prevent capturing the SynchronizationContext, making the library environment-agnostic and avoiding potential deadlocks.
#11about 4 minutes
Q&A: SynchronizationContext, tooling, and challenges
The Q&A session clarifies that frameworks like Blazor still use SynchronizationContext in .NET Core and discusses debugging tools like Visual Studio's Parallel Stacks.
Related jobs
Jobs that call for the skills explored in this talk.
Senior Softwareentwickler (m/w/d)
PROSOZ Herten GmbH
Herten, Germany
Remote
€59-80K
Intermediate
Senior
.NET
C#
+3
Senior Fullstack Engineer – Angular/.Net (f/m/d)
Apaleo
München, Germany
Remote
€65-85K
Senior
JavaScript
.NET
+2
Matching moments
20:38 MIN
Overcoming thread limitations with event-driven programming
Concurrency in Python
07:03 MIN
The evolution from threads to modern concurrency
Concurrency with Go
25:49 MIN
Using coroutines to write linear asynchronous code
Coroutine explained yet again 60 years later
03:13 MIN
Demystifying asynchronous execution with the event loop
Multithreading in Javascript: A guide to Web Workers
00:44 MIN
Defining concurrency, parallelism, and multitasking
Concurrency in Python
24:24 MIN
Writing concurrent code with async and await
Concurrency in Python
35:31 MIN
Implementing advanced patterns for resilience and decoupling
Cloud-nativeApplications- What’s the buzz about
07:45 MIN
How to await async void methods in C#
Hacking C# from the inside - how to do anything in NET
Featured Partners
Related Videos
Tips, tricks and quirks in .NET
Paweł Łukaszuk
Turbocharged: Writing High-Performance C# and .NET Code
Steve Gordon
Concurrency in Python
Fabian Schindler
The Eventloop in JavaScript - How does it work?
Christian Woerz
Concurrency with Go
Frank Müller
WebAssembly: Disassembled
Stefan Schöberl
Multithreading in Javascript: A guide to Web Workers
Dani Coll
Blazor – the new SPA Framework for everyone who hates JavaScript
Christian Giesswein
Related Articles
View all articles.gif?w=240&auto=compress,format)



From learning to earning
Jobs that call for the skills explored in this talk.
![Senior Software Engineer [TypeScript] (Prisma Postgres)](https://wearedevelopers.imgix.net/company/283ba9dbbab3649de02b9b49e6284fd9/cover/oKWz2s90Z218LE8pFthP.png?w=400&ar=3.55&fit=crop&crop=entropy&auto=compress,format)
Senior Software Engineer [TypeScript] (Prisma Postgres)
Prisma
Remote
Senior
Node.js
TypeScript
PostgreSQL


Tech Lead (m/f/d) - Berlin
Patronus Group
Berlin, Germany
Senior
Kotlin
Spring Boot
Amazon Web Services (AWS)

DevOps Engineer – Kubernetes & Cloud (m/w/d)
epostbox epb GmbH
Berlin, Germany
Intermediate
Senior
DevOps
Kubernetes
Cloud (AWS/Google/Azure)


Senior .Net Core Engineer with Cloud and Containers Experience
Cognizant
Zürich, Switzerland
Senior
JIRA
Scrum
Jenkins
.NET Core
Kubernetes
+1

Fullstack con Angular y .Net Core 100% teletrabajo
Cibernos
Municipality of Madrid, Spain
Remote
Intermediate
API
GIT
MongoDB
Angular
+1

SOFTWAREENTWICKLER C# / .NET / ANGULAR
Glatthaar Keller GmbH & Co. KG
Bautzen, Germany
Remote
CSS
GIT
HTML
.NET
+6
