Say we have the following two methods inside a standard mvc controller.
public class SomeController : Controller
{
public async Task<Response> SomeAction1()
=> await _someService.SomeAsyncMethod();
public Task<Response> SomeAction2()
=> _someService.SomeAsyncMethod();
// SomeAsyncMethod might look like this.
// public async Task<Response> SomeAsyncMethod()
// => await someDbAction();
}
Simple question: does the base controller class execute a task as awaited/async?
Alternately do both of these actions do the exact same thing?
-- Edit for a bit of clarification. --
How Requests Are Processed by the Thread Pool
On the web server, the .NET Framework maintains a pool of threads that are used to service ASP.NET requests. When a request arrives, a thread from the pool is dispatched to process that request. If the request is processed synchronously, the thread that processes the request is busy while the request is being processed, and that thread cannot service another request.
My goal is to understand if a method returning a Task needs to be accompanied with the word async
. If the keyword is not there will it treat the method as synchronous and hold up the thread even though SomeAsyncMethod
has an await
in it creating the callback?