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

Describe management functions and explain how each of them is interrelated./ Four key functions (planning, organizing, directing and controlling) make up the process of management. It is possible that the controlling function can affect the organizing function and organizing function can affect the leading functions? Explain.

Short note on E-Government Architecture

TU IT Sahayak Word processing