Define Asynchronous programming techniques with examples of async/ wait functions.

 Asynchronous programming techniques

  • Asynchronous programming in C# is an efficient approach towards activities blocked or access is delayed.
  • If an activity is blocked in a synchronous then, the complete application waits and it takes more time. By using the asynchronous approach the applications continue with other ' tasks as well.'
  • The async and await keywords in C# are used in async programming. Using them, we can work with .Net resources, .Net Core, etc.

Example:

using System;

using System. Threading. Tasks;

namespace My Console App

{

 Class Async Await Test 

{

 Static void Main (string [ ]args)

{

 Method1(); 

Method 2(); 

Console. ReadKey ();

public static async Task Method1()

await Task.Run(() => 

{

 for(int & i= 0; i ≤ 100; i++) 

Console Write Line ("Methed 1");

}

});

}

 public static void Method 2 

{

 for (int i=0; i <25, i++)

{

Console.WriteLine (Method 2"); 

}

}

}

}

Comments

Popular posts from this blog

What is the cloud cube model? Explain in context to the Jericho cloud cube model along with its various dimensions.

Discuss classification or taxonomy of virtualization at different levels.

Short note on Uniform Gradient Cash Flow and PERT