0

If I have async middleware in ASP.NET Core 6/7 and I am getting 1000 requests, will there be 1000 threads (created by async) and one main thread?

public async Task InvokeAsync(HttpContext context)
{
    await _next(context);
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Rushee
  • 766
  • 7
  • 18
  • 2
    https://devblogs.microsoft.com/dotnet/how-async-await-really-works/ / https://blog.stephencleary.com/2013/11/there-is-no-thread.html – Jeremy Lakeman Jun 02 '23 at 06:27
  • 1
    TLDR; if your tasks are waiting for I/O, then they do not consume a thread. Only when I/O completes and more code needs to run, then your task will take a thread from a thread pool. The thread pool will grow if you have too many CPU bound tasks. – Jeremy Lakeman Jun 02 '23 at 06:31

0 Answers0