Execute Method asynchronous using Threading

Solution:

using System.Threading;

 

 

        // on button click , procedure for starting thread

        private void button2_Click(object sender, EventArgs e)

        {

            // create thread with passing function name in constructor

            Thread t = new Thread(new ThreadStart(called));

 

            //start the thread

            t.Start();

        }

        protected void called()

        {

            int i=0;

            // infinite loop

            while(i>=0)

            {

                Console.WriteLine(i);

                i = i + 1;

 

            }

        }