• home
  • Email: trainings@synapseindia.careers

Blogs

back

Understanding Async and Await in C#

Jun 01, 2015

The latest version of the C# language – version 5 – introduced two new keywords to express  asynchronous operations: async and await. These keywords let you write simple code that utilizes the Task Parallel Library to execute long running operations (such as network access) in another thread and easily access the results on completion.

Let us understand some of the important points about it :

  1. Asynchrony is essential for activities that are potentially blocking, such as when your application accesses the web. Access to a web resource sometimes is slow or delayed. If such an activity is blocked within a synchronous process, the entire application must wait. In an asynchronous process, the application can continue with other work that doesn't depend on the web resource until the potentially blocking task finishes.
  2. Asynchrony proves especially valuable for applications that access the UI thread because all UI-related activity usually shares one thread. If any process is blocked in a synchronous application, all are blocked. Your application stops responding, and you might conclude that it has failed when instead it's just waiting. When you use asynchronous methods, the application continues to respond to the UI. You can resize or minimize a window, for example, or you can close the application if you don't want to wait for it to finish.
  3. The async-based approach adds the equivalent of an automatic transmission to the list of options that you can choose from when designing asynchronous operations. That is, you get all the benefits of traditional asynchronous programming but with much less effort from the developer.
  4. The latest versions of Xamarin.iOS and Xamarin.Android also support async and await .
 async and await keywords in C# are the heart of async programming. By using those two keywords, you can use resources in the .NET Framework or the Windows Runtime to create an asynchronous method almost as easily as you create a synchronous method. Asynchronous methods that you define by using async and await are referred to as async methods.

SynapseIndia (CEO: Shamit Khemka)

2 thoughts on “Understanding Async and Await in C#

  1. Must to know that async and await keywords in C# are the heart of async programming. By using those two keywords, you can use resources in the .NET Framework.

Leave a Reply

Your email address will not be published.