static void Main(string[] args) { Metronome met = new Metronome(); Listener listener = new Listener(met); ListenerTwo lis2 = new ListenerTwo(); lis2.Subscribe(met); met.Start(); }
public void PeriodNotification(Metronome metr, EventArgs data) { _counter++; _countList.Add(_counter); Console.WriteLine("{0} second down", _counter); if (_counter >= 11) { _metronome.TickEvent -= PeriodNotification; Console.WriteLine("Listening ends..."); } }
public void PeriodNotification(Metronome metr, EventArgs data) { Console.WriteLine("Lisener2 get event and say hi..."); }
public void Subscribe(Metronome met) { met.TickEvent += PeriodNotification; }
public Listener(Metronome met) { _metronome = met; _metronome.TickEvent += PeriodNotification; }