Thread Behavior In Synchronous And Asynchronous Method

In most applications, the UI system displays components which are not dependent on each other in order to be loaded. In such cases, synchronous programming takes more time to load than respective page completely, whereas asynchronous programming loads the page irrespective of remaining or ongoing asynchronous tasks.

Given below is the illustration of requests execution in synchronous and asynchronous programming.

In C#, by default method executes in a synchronous manner. As we see in the above diagram, synchronous methods get blocked until execution of previous request is completed whereas in asynchronous execution an await expression in an async method doesn’t block the current thread while the awaited task is running. 

The async and await keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread.

Thread behavior during synchronous execution

Thread behavior during Asynchronous execution

Happy Coding :)

Reference

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/task-asynchronous-programming-model


Similar Articles