Exemple #1
0
        static void Main()
        {
            var palabra = new Alarma()
            {
                msg = "Mensaje de alarma"
            };
            var AlarmaV = new Alarmclock(); //piblisher

            var ShowA = new ShowAlarm();    //subscriver

            AlarmaV.AlarmaEvento += ShowA.onAlarma;



            AlarmaV.Alarm(palabra);
        }
Exemple #2
0
        public void Alarm(Alarma msg)
        {
            Console.WriteLine("Alarma");

            //Thread.Sleep(3000);
            int i = 0, j = 0;

            do
            {
                i = DateTime.Now.Second;
                if (i % 12 == 0 && j != i)
                {
                    j = i;
                    Console.WriteLine(DateTime.Now.Second);
                    onAlarma();
                }
                if (i % 30 == 0 && j != i)
                {
                    j = i;
                    Console.WriteLine(DateTime.Now.Second);
                    onAlarma();
                }
            } while (DateTime.Now.Second < 59);
        }