// a method to raise the event public void CheckBlanace(int x) { // only fire event based on a condition if (x > 250) { // prepare custom event arguments MyEvtArgs evtArgs = new MyEvtArgs("Balance of " + x + " exceeds 250"); // fire event eventToFire(sender: this, e: evtArgs); } }
// a method to handle event with custom event argumenets - MyEvtArgs public void HandleEvent(object sender, MyEvtArgs e) { Console.WriteLine("Event Fired and Handling - " + "ATTENTION - " + sender + " is advising " + e.Message); }