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++; } }
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); }
static void Main(string[] args) { Timer timer = new Timer(PrintText, 10, 1000); timer.Start(); }