Beispiel #1
0
        static void Main(string[] args)
        {
            Timer myTimer = new Timer(3000, delegate { Console.WriteLine(DateTime.Now); });

            Timer myTimer2 = new Timer(2000, delegate { Console.WriteLine(1); });

            int i = 0;
            while (true)
            {
                if (i == int.MaxValue || i == int.MinValue)
                {
                    Console.WriteLine(i);
                }
                i++;
            }
        }
Beispiel #2
0
        static void Main()
        {
            Timer newTimer = new Timer();

            //Add methods to the Void Methods delegate
            newTimer.AddVoidMethodsToExecute(Method1);
            newTimer.AddVoidMethodsToExecute(Method2);

            //Execute the methods in the Void Methods delegates 3 times with 1s delay
            newTimer.StartExecutionVoidMethods(1, 3);

            //Add methods to the Int Methods delegate
            newTimer.AddIntMethodsToExecute(Method3Subtract);
            newTimer.AddIntMethodsToExecute(Method4Add);
            newTimer.AddIntMethodsToExecute(Method5Product);

            //Execute the methods in the Int Methods delegates 2 times with 2s delay
            newTimer.StartExecutionIntMethods(2, 2, 100, 50);
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     Timer timer = new Timer(PrintText, 10, 1000);
     timer.Start();
 }