When to use asynchronous tasks in asp.net core mvc?

Partha Mandayam 91 Reputation points
2022-07-13T05:03:36.777+00:00

Can you give practical scenario and explain why we need to use asynchronous tasks there?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
3,995 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Dillon Silzer 52,581 Reputation points
    2022-07-13T05:16:09.343+00:00

    Please see the documentation below for more of an explanation:

    220150-image.png

    https://learn.microsoft.com/en-us/aspnet/mvc/overview/performance/using-asynchronous-methods-in-aspnet-mvc-4

    Also here is an example from C# to help you understand from a real-life example:

    220263-image.png

    https://learn.microsoft.com/en-us/dotnet/csharp/async

    0 comments No comments

  2. Bruce (SqlWork.com) 52,401 Reputation points
    2022-07-13T16:32:39.607+00:00

    following the node model, to gain perform asp.net core decided to use a limited number of request pipeline threads (cpu count) and depend on async processing to allow the same thread to process multiple requests concurrently.

    if you need scaling (large number of concurrent requests), then you need to use async for all network, database, file, and any long computing tasks. that is is an api supports an async version, you should use the async version. if you don't, your site will run fine, it just will not scale up to a large number of requests.

    0 comments No comments

  3. SurferOnWww 1,626 Reputation points
    2022-07-14T01:04:18.343+00:00

    When to use asynchronous tasks in asp.net core mvc?

    Can the following Microsoft documents help?

    Async Programming : Introduction to Async/Await on ASP.NET
    https://learn.microsoft.com/en-us/archive/msdn-magazine/2014/october/async-programming-introduction-to-async-await-on-asp-net

    ASP.NET Core Performance Best Practices
    https://learn.microsoft.com/en-us/aspnet/core/performance/performance-best-practices?view=aspnetcore-6.0

    0 comments No comments