Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6067427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:36:24+00:00 2026-05-23T09:36:24+00:00

I am using a class raising an event that doesn’t contain in the signature

  • 0

I am using a class raising an event that doesn’t contain in the signature of it’s event handler a parameter for the sender object.

How can I, from the event handler, determine which object raised the event? how do I get a reference to this object? Can it be done using reflection?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:36:24+00:00Added an answer on May 23, 2026 at 9:36 am

    The best way I can think to do this is by using something like the Adapter Pattern. You would basically create a class inside your code that wraps the COM class you’re building, which contains its own event that can provide more detailed information. Each instance of your class would create its own instance of the COM class, handle the COM events, and raise its own events to the rest of your code. So, you don’t know exactly which COM class is raising the event, but you do know which of your own class instances it is.

    But, this type of solution would heavily depend on exactly what you’re trying to accomplish. If you’re just trying to get better debug information, this is a good route to take, but if you’re trying to wire together parts of someone else’s library, there are many situations in which this wouldn’t accomplish anything.

    public class MyClass
    {
       private COMClass instance;
       public event EventHandler<BetterEventArgs> MyBetterEvent;
    
       public MyClass()
       {
          instance.event += new EventHandler(Handle_COM_event); // ... or whatever
       }
    
       public void Handle_COM_event(EventArgs)
       {
          if(MyBetterEvent != null) MyBetterEvent(this, new BetterEventArgs());
       }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update 3/4: I've done some testing and proved that using checkout event handler to
Using class name I am firing a click event in jquery. Class names are
I am using this class to load multiple images synchronously. Somehow the loader doesn't
I'm using a class that forwards events in C#. I was wondering if there's
I am using the class pasted below to listen for the keypress event ctrl
I'm using class that is not called by my @Controller directly and when I
Any efficient/reliable way to expose one event? I have a class, MultipleDocumentCopier that copies
I have a problem with raising an event on a mocked object. I am
Using class table inheritance it is recommended that the subclass refers to the superclass
I wrote a simple program that using Class::ArrayObjects but It did not work as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.