Software & Finance





C# - Using Timer Function





I have given a simple C# program using a timer function.


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading;

 

namespace ConsoleApplication1

{

    class Program

    {

 

        static int m = 100;

 

        static void Timer_Trigger(object data)

        {

            Console.WriteLine(m);

            m += 100;

        }

 

        static void Main(string[] args)

        {

            Timer myTimer = new Timer(Timer_Trigger, "IDX001", (long)0, (long)200);

 

            string dummy = System.Console.ReadLine();

        }

    }

}

 

output:

100

200

300

400

500

 

This will continue until you hit <ENTER> key