Пример #1
0
        public Subscriber(string id, Sender sender)
        {
            this.id = id;

            //步骤6.用+=操作符添加事件到事件队列中(-=操作符能够将事件从队列中删除)。
            sender.DebugEvent += new DemoEventHandler(MyEvent);
        }
Пример #2
0
 static void Main(string[] args)
 {
     Sender sender = new Sender();
     Subscriber subscriber1 = new Subscriber("1",sender);
     Subscriber subscriber2 = new Subscriber("2",sender);
     sender.Debug("demo");
     Console.ReadKey();
 }