Asynchronous programming is very helpful in cases where we are expecting various activities at the same point in time. With the async keyword, we define our method/operation as asynchronous. Consider the following code snippet:
internal class AsyncAwait
{
public async Task ShowMessage()
{
Console.WriteLine("\tServing messages!");
await Task.Delay(1000);
}
}
Here, we have a AsyncAwait class with an async method, ShowMessage(). This method is simply printing a message that would show in the console window. Now, whenever we call/consume this method in another code, that part of the code could wait/hold/block the operation until the ShowMessage() method executes and completes its task. Refer to the following snapshot:
Our previous screenshot says that we have set a delay of 1,000 milliseconds for our ShowMessage...