December 2019
Intermediate to advanced
510 pages
11h 33m
English
Since its introduction in the old ASP.NET framework, the async/await code was previously affected by some deadlock issues. The old version of ASP.NET uses a class called SynchronizationContext, which essentially provides a way to queue a Task to a context when a method calls other tasks that are nested asynchronous methods and forces them to be executed synchronously using the .Result or .Wait() keywords, therefore, this causes a deadlock of the request context.
For example, let's suppose that the following code is executed on the old version of ASP.NET:
public class ValuesController : ApiController { public string Get() { return Operation1Async().Result; } public async Task<string> Operation1Async() { await Task.Delay(1000); ...