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 allow the machine to do additional work - for example, to allow the calling thread to do other work while it’s waiting for a result from some I/O operation. In this case, the calling thread is never allowed to do more work than it would have been able to do otherwise, so there’s no performance gain over simply calling MethodA(), MethodB(), and MethodC() synchronously.

Feedback about page:

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


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

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
111 Async Await
127 Caching
135 Pointers
147 C# Script