Events or Class Overrides ?

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

..NET Events and class method overrides through inheritance provide similar functionality for class consumers. Does anyone know (for
sure) which performs better? How much better? Also interested in all opinions about the strategy of choosing one over the other?
Perhaps general or specific situations where one leaves more options open?

TIA for any perspective you can provide based on your experience.

Best regards - Lee Gillie, Spokane WA
 
The general guidelines (AFAIK) are as follows:

For derived classes, override then Base method (usually named "OnSomething"
where "Something" is the name of the event). This cuts out the extra
processing needed to invoke an event (which uses multicast delegates). Just
remember to call the base class method so it can do its own processing.

For classes that don't inherit from the base class, you have no choice but
to use its events - you can't catch calls to it's methods by overriding
them.

HTH,

Trev.

Lee Gillie said:
.NET Events and class method overrides through inheritance provide similar
functionality for class consumers. Does anyone know (for
sure) which performs better? How much better? Also interested in all
opinions about the strategy of choosing one over the other?
 
Back
Top