OneCompiler

Asynchronous

150

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Practice_Module
{
class Asynchronous
{

    static async Task Main(string[] args)
    {
        LongProcess();

        ShortProcess();
    }

    static async void LongProcess()
    {
        Console.WriteLine("LongProcess Started");

        await Task.Delay(4000); // it does not hold execution for 4 seconds because it is async 

        Console.WriteLine("LongProcess Completed");

    }

    static void ShortProcess()
    {
        Console.WriteLine("ShortProcess Started");

        //do something here

        Console.WriteLine("ShortProcess Completed");
    }
}

}