Beispiel #1
0
 public IAsyncResult TriggerEvent()
 {
     Thread.Sleep(1000);
     if (MyEvent != null)
     {
         return(MyEvent.BeginInvoke(this, EventArgs.Empty, null, null));
     }
     return(null);
 }
 //3.1定义触发事件的方法
 public void OnMyEvent(object sender, MyEventArgs args)
 {
     //异步执行事件上锁绑定委托的方法
     MyEvent?.BeginInvoke(sender, args, null, null);
 }