474,027 Members | 2,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Events or Class Overrides ?

..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
Nov 20 '05 #1
1 895
The general guidelines (AFAIK) are as follows:

For derived classes, override then Base method (usually named "OnSomethin g"
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" <AN************ *******@odp.com > wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
.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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1711
by: ECVerify.com | last post by:
This should be a basic question. In VB.NET in the two drop downs over the source code for a form you can get a list of the events and overrides for that form. In VC++ in the properties window you can get the events and overrides. But for some reason I can not seem to find the list of events and overrides for a C# form, if I do this. the Intelisense will show them but as for being able to select it and have the IDE pop the function or...
10
2169
by: Chad Miller | last post by:
I currently have a base form that I inherit. The base for has a custom event. The event will not raise threw the inherited form. I was wondering if events work threw inheritance or should I use some other method? -- Chad Miller President and Director of Software Development Predictive Concepts, Inc. www.predictiveconcepts.com 407.327.9910
4
1361
by: Charles Law | last post by:
In a form, there is a set of events that can be handled. There is also a list of (Overrides). So, for the Closed event, for example, there is an override OnClosed. Where should exit code be placed: in the Closed event handler, or in the OnClosed override function? What is the difference, and why have the two? When would I use each one?
4
1416
by: Bill English | last post by:
How do I assign a method to the click event of a specific toolbar button? When I look under ToolbarButton1 events, all I see is disposed.
3
3232
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI container form) or if the MDI child form's Visible property is set to False (after the MDI child form was shown). This is an enormous problem for my app because I must show different MDI child forms based on the state of my application and many of the...
2
1228
by: Lars Netzel | last post by:
I have used a TableStyle to add a ComboBox column in a cell in a datagrid. Now I need to catch the SelectedIndexChanged from the datagrid cell... but I have no clue at all on how to do this! /Lars
2
1325
by: Dennis | last post by:
I have a control that inheirts from "Panel". I want to prevent the user from having access to the MoueUp event. I tried making a sub in my control that handles MyBase.MouseUp but still this event shows up as an event the user can use. Is there anyway to prevent users of this control from getting access to events such as MouseUp. Thanks. -- Dennis in Houston
10
3149
by: Dennis | last post by:
I have a simple form with one button and one text box. In the Form, I create an array list to track the events by adding a descriptive string item to the arraylist in each event. I first Click on the Button then Click on the TextBox and enter an "a" then click on the Button again. The following is what I get for the event tracking Arraylist: but - GotFocus but - Clicked but - LostFocus txt - Changed
2
1635
by: Bert Szoghy | last post by:
Hello, I am missing something about Visual Basic .NET module variables and window close events. In the following code, after opening Form2 by clicking a button on Form1 and then closing Form2, I would expect to click on the second Form1 button and get intMyValue = 0. Form2 has code to reinitialize it in its close event, but this doesn't seem
0
10499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
12070
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11567
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
11091
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6605
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5355
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4903
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.