Re: Consuming your own events.
Sebastien Lambla <[email protected]> Wed, 30 Jan 2008 16:20:12 +0000
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
> So, to summarize: prefer RaiseX over OnX because RaiseX is more > explicit > that the method is meant to only raise an event. If you use the OnX > pattern and only raise events from that method and overrides, you'd > have > the same thing... Prefer the raise because the intent is clearer than the On that is either used to raise events or to handle event notifications depending on which part of the .net framework you're using. If you want your observers to cancel an event, use the Xxxing / Xxxed with a CancelableEventArg to cancel the raising of the second event. If you want your children to cancel an event, that's a gray area. I'm not opposed to making RaiseXxx virtual, but it provides the possibility of implementing behaviour in children classes and causes the same issue of forgetting to call the base RaiseXxx. But there's so much you can do, and forgetting to call base.Raise has much stronger sematnics than base.On -- SerialSeb =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com