Articles → CSHARP → Async And Await In C#

Async And Await In C#






Purpose





Example


class Program
{
        static void Main(string[] args)
        {            
            Program.CallAsyncMethod();
            Console.ReadLine();
        }

        public static async void CallAsyncMethod()
        {
            await Task.Run(() =>
            {
                Console.WriteLine("Async method");
                // Write the time consuming logic here.
            });
        }
}



Output


Picture showing the output of async and await in C#
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, January 20, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250