Articles → .NET → 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



Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250