Async Await will only improve performance if it allows the machine to do additional work

suggest change

Consider the following code:

public async Task MethodA()
{
     await MethodB();
     // Do other work
}

public async Task MethodB()
{
     await MethodC();
     // Do other work
}

public async Task MethodC()
{
     // Or await some other async work
     await Task.Delay(100);
}

This will not perform any better than

public void MethodA()
{
     MethodB();
     // Do other work
}

public void MethodB()
{
     MethodC();
     // Do other work
}

public void MethodC()
{
     Thread.Sleep(100);
}

The primary purpose of async/await is to let the machine do other work — for example, to let the calling thread run other requests while it waits for I/O. In this chain, nothing overlaps the delay: each method awaits the next one before its own “other work,” so the latency is no better than calling MethodA, MethodB, and MethodC synchronously. Task.Delay still releases the thread, unlike Thread.Sleep, which can matter for a server even when this call chain itself is no faster.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents