Exemplo n.º 1
0
 //事件检查内部方法, 事件触发时机达到后, 检查是否可以真正的告诉各个listener
 //如果有子类, 子类应该有是否真正触发事件的选择权
 protected virtual void OnEventTrigger(MyEventArg args)
 {
     //TODO thrading problem
     if (myEvent != null)
     {
         myEvent.Invoke(this, args);
     }
 }
Exemplo n.º 2
0
        //事件触发公开方法, 别人调用它代表事件准备触发
        public void SomethingHappens(int i, string s)
        {
            MyEventArg args = new MyEventArg(i, s);

            OnEventTrigger(args);
        }
Exemplo n.º 3
0
 //Listener定义如何处理事件
 private void EventHandlerOne(Object sender, MyEventArg e)
 {
     Console.WriteLine("ListenerOne is handling event from " + sender.GetType() +
                       ". Dealing with info of [" + e.IntInfo.ToString() + "] and " + "[" + e.StringInfo + "].");
 }
Exemplo n.º 4
0
 static void TempHandleMany_2(Object sender, MyEventArg e)
 {
     Console.WriteLine("Handling event 2 of many events class");
 }
Exemplo n.º 5
0
 protected override void OnEventTrigger(MyEventArg args)
 {
     //子类选择无论如何都不触发事件
     return;
 }