473,734 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

EventHandling problem : Java has solution but what about Microsoft???

Hi,
I have added few of the events in some control, example code is:
btnControl.GotF ocus +=new EventHandler(Ev entHandlingMeth od);
btnControl.Clic k +=new EventHandler(Ev entHandlingMeth od);
lblControl.Clic k +=new EventHandler(Ev entHandlingMeth od);

private void EventHandlingMe thod(object sender, EventArgs e)
{
.......
}

btnControl = Button object, lblControl = Lable object

Now the problem is: I am adding the same event handler method in all events for btnControl and lblControl too.

now in EventHandlingMe thod method, i can find which control is using sender but now if i want to put some switch cases in the method for Event Name then I have no any such information in the eventargs or anyother way....

Can someone help/guide me to get the event name?

Is it possible? if yes then how? If no, then any work around?

Thanks in Advance

Regards,
Mahesh Devjibhai Dhola

Nov 29 '05
21 1354
I don't know how log4net handles this, but I guess it uses the Stack
also.
I have no idea about the rules compiler uses to decide to inline a
function, but the logging routines is in a separate class in a separate
assembly. Does the runtime ever decide to inline such methods?

Thi

Dec 2 '05 #21
Truong Hong Thi wrote:
I don't know how log4net handles this, but I guess it uses the Stack
also.
I have no idea about the rules compiler uses to decide to inline a
function, but the logging routines is in a separate class in a separate
assembly. Does the runtime ever decide to inline such methods?

Thi


AFAIK, the JIT currently inlines methods that have 32 or less IL bytes.
As for the problem, I think you don't need to worry about it, as it's
mostly theoretical. It can happen like this:

using System;
using System.Diagnost ics;
using System.Runtime. CompilerService s;

namespace Test
{
class Program
{
static void Main(string[] args)
{
Method1();
}

static void Method1()
{
Method2();
}

static void Method2()
{
WriteCallee();
}

[MethodImpl(Meth odImplOptions.N oInlining)]
static void WriteCallee();
{
Console.WriteLi ne(new StackFrame(1).G etMethod().Name );
}
}
}

in debug mode (inlining disabled) the output is Method2, whereas in
release mode the output is Main

HTH,
Stefan

Dec 2 '05 #22

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

Similar topics

4
2418
by: Marc Tanner | last post by:
Hello, I am currently working on a eventhandling system or something similar, and have the problem of loosing scope. I have read many interesting posts on this group and the faq article about closure, but it seems that i have still not understood everything. Below is my attempt to preserve the scope but it's not really nice and i think with the use of closure could it be done better. But at the moment i am quite confused and hope that...
3
1187
by: Claes Rådström | last post by:
Hi ! We have a base class that derives from System.Web.UI.Page Alla our pages derives from it. In our base class we want to have an access check, (own) , to verfy user access to the derived page. We want this in the base class so that the programmer cant forget to implement it. => we want a page load in the base class to fire first, if access is granted
12
1287
by: Mahesh Devjibhai Dhola [MVP] | last post by:
Hi, I have added few of the events in some control, example code is: btnControl.GotFocus +=new EventHandler(EventHandlingMethod); btnControl.Click +=new EventHandler(EventHandlingMethod); lblControl.Click +=new EventHandler(EventHandlingMethod); private void EventHandlingMethod(object sender, EventArgs e) { ....... }
0
8946
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
9449
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
9310
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...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
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...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.