Async - Code Snippets
Async - Code Snippets
Code Snippets
Difference between Synchronous and Asynchronous programming
In below code – code 1.0, Method2 needs to wait for Method1 to complete execution. To solve this
problem, we use async programming with the help of Task in code 1.1
[Link](Method1());
[Link](Method2());
[Link](Method3());
[Link]("End");
}
[Link]();
[Link]("End");
}
using System;
using [Link];
public class HelloWorld
{
public static void Main(string[] args)
{
[Link] ("Main start");
Method1();
[Link]("Main end");
}
public static async void Method1()
{
[Link]("Method1 start");
await Method2();
[Link]("Method1 end");
}
Output:
Main start
Method1 start
Method2 start
Main end
Method2 end
Method1 end
Most asked Async and Await output based interview questions and answers #coding #shorts
#csharp
Reference