示例#1
0
文件: Program.cs 项目: fars/CSharp_ex
        static void Main(string[] args)
        {
            Metronome   met      = new Metronome();
            Listener    listener = new Listener(met);
            ListenerTwo lis2     = new ListenerTwo();

            lis2.Subscribe(met);
            met.Start();
        }
示例#2
0
文件: Program.cs 项目: fars/CSharp_ex
 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...");
     }
 }
示例#3
0
文件: Program.cs 项目: fars/CSharp_ex
 public void PeriodNotification(Metronome metr, EventArgs data)
 {
     Console.WriteLine("Lisener2 get event and say hi...");
 }
示例#4
0
文件: Program.cs 项目: fars/CSharp_ex
 public void Subscribe(Metronome met)
 {
     met.TickEvent += PeriodNotification;
 }
示例#5
0
文件: Program.cs 项目: fars/CSharp_ex
 public Listener(Metronome met)
 {
     _metronome            = met;
     _metronome.TickEvent += PeriodNotification;
 }