/// <summary> /// 開始揍人 /// </summary> /// <param name="personName">被揍的人</param> public void punchSomeBody(string personName) { string tool = "Apple"; int count = 2; PunchingEventArgs punchingEventArgs = new PunchingEventArgs(personName, count, tool); this.OnPunching?.Invoke(this, punchingEventArgs); if (punchingEventArgs.Cancel) { return; } System.Threading.Thread.Sleep(3000); PunchedEventArgs punchedEventArgs = new PunchedEventArgs(personName, count, tool); //if (this.Punch != null) //{ // this.Punch(this, EventArgs.Empty); //} // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ this.OnPunched?.Invoke(this, punchedEventArgs); //打完了 }
private static void Antony_OnPunching(object sender, PunchingEventArgs e) { Console.WriteLine("Antony 要打{1}啦! @{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now, e.Name); e.Cancel = true; }