NET Core and More

TH12 Use Async Internals in .NET


11:00am - 12:15pm

Level: Intermediate to Advanced

Adam Furmanek

Software Developer


Async and await are now common elements of .NET ecosystem. Do you know how they work? Do you know what is synchronization context, how to wait for async void methods or how to implement custom task scheduler?

In this talk I show internals of async and await. I present state machine created by the compiler, consider allocation issues and show typical deadlock scenarios. We will see how to call async methods from synchronous code, how to wait for async void, how to implement custom synchronization context or task scheduler to handle exceptions, and how to run task without allocation at all.

You will learn:

  • Understanding state machine generated by the compiler when compiling async/await
  • Understanding synchronization context and thread pool, implementing own solution to await async void methods or handle exceptions
  • Understanding memory usage and how to minimize it