static void Main(string[] args)
 {
     Console.WriteLine("Before timer");
     int t = 10000;
     Console.WriteLine($"Timer - {t} miliseconds");
     Timer timer = new Timer(t);
     Microwave microwave = new Microwave(timer);
     timer.Start();
     Console.WriteLine("Started");
     Thread.Sleep(2000);
     Console.WriteLine("2000");
     Console.WriteLine("Adding oven");
     Oven oven = new Oven();
     oven.RegisterTimer(timer);
     Console.WriteLine("Awaiting timer");
     timer.WaitRing();
     Console.WriteLine("Ring");
     Console.ReadLine();
 }
        static void Main(string[] args)
        {
            Console.WriteLine("Before timer");
            int t = 10000;

            Console.WriteLine($"Timer - {t} miliseconds");
            Timer     timer     = new Timer(t);
            Microwave microwave = new Microwave(timer);

            timer.Start();
            Console.WriteLine("Started");
            Thread.Sleep(2000);
            Console.WriteLine("2000");
            Console.WriteLine("Adding oven");
            Oven oven = new Oven();

            oven.RegisterTimer(timer);
            Console.WriteLine("Awaiting timer");
            timer.WaitRing();
            Console.WriteLine("Ring");
            Console.ReadLine();
        }
示例#3
0
 static void Main(string[] args)
 {
     Timer t = new Timer(2);
     t.IntervalPassed += Tick;
     t.Run();
 }