About

Showing posts with label Execute one async and normal method C#. Show all posts
Showing posts with label Execute one async and normal method C#. Show all posts

Tuesday, September 24, 2019

Execute one async and normal method  C#


We have two methods in below example 
1. Without await functionality with async key word
2. Without await and async method/functionality(normal method )

The below example is  methods will be executing in  asynchronous action.

Example : 
 static void Main(string[] args)
        {
            GetTaskAsync();
            NormalMethod();
            Console.Read();
        }
        static async Task  GetTaskAsync()
        {
            await Task.Run(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine(" GetTaskAsync");
                }
            });
        }

        static void NormalMethod()
        {
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine(" NormalMethod");
            }
        }
    }

OutPut : 

Conclusion : As per above points with async and with out await key words the functionality will work like asynchronous

Please add the comments then I can improve the blog thank you