Cancelling await calls in .NET 6 with Task.WaitAsync()

added by DotNetKicks
3/8/2022 10:45:18 AM

338 Views

In this post I discuss the new Task.WaitAsync() APIs introduced in .NET 6, how you can use them to "cancel" an await call, and how they can replace other approaches you may be using currently. In a recent post, I described how to use a TaskCompletionSource with IHostApplicationLifetime as a way of "pausing" a background service until the application starts up.


0 comments