Get the latest tech news
Asynchronous Programming in C#
This repository has examples of broken patterns in ASP.NET Core applications - davidfowl/AspNetCoreDiagnosticScenarios
For instance, in the event of an unhandled exception in a manually created thread, the application will crash (unless handled via AppDomain.CurrentDomain.UnhandledException), but with.LongRunning, it will be wrapped into a Task as an AggregateException. It's always faster to directly return the Task since it does less work but you end up changing the behavior and potentially losing some of the benefits of the async state machine. ⚠️ It might be tempting to update the logic in DisposableThing.Current to mutate the original execution context instead of setting the async local directly ( StrongBox<T> is a reference type that stores the underlying T in a mutable field):
Or read this on Hacker News