Handling aborted requests in ASP.NET Core

  • ASP.NET Core
  • .NET
  • Web
When a user make a request to an ASP.NET Core application, the server parses the request, generates a response, and sends the result to the client. The user can abort the request while the server is processing it. For instance the user can navigate to another page or close the page. In this case, you may want to stop all the work in progress to avoid consuming resources. For instance, you may want to…[read more]

Get the result of multiple tasks in a ValueTuple and WhenAll

  • .NET
In .NET, you can use Task.WhenAll to wait for multiple tasks. Once the tasks are completed, you can get the results using .Result or by awaiting them. Task<int> task1 = Task.Run(() => 1); Task<string> task2 = Task.Run(() => "meziantou"); await Task.WhenAll(task1, task2); var task1Result = task1.Result; // or await task1 var task2Result = task2.Result; // or await task2 I don't really want write this…[read more]