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 6611385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:57:46+00:00 2026-05-25T19:57:46+00:00

I was reading this page and I noticed how it said this is standard

  • 0

I was reading this page and I noticed how it said this is standard guidelines:

The .NET Framework guidelines indicate that the delegate type used for an event should take two parameters, an “object source” parameter indicating the source of the event, and an “e” parameter that encapsulates any additional information about the event.

I can understand how having an object sender could be useful in some circumstances, but I could see the exact opposite in others. For example,

  1. What if a class handling the event should not have any knowledge about who fired it? Coupling, cohesion, and all of that.

  2. In my case, I already have a reference to the object as a member variable. That is how I subscribe to the event. There will only ever be one instance of it so there’s no reason to cast the sender object rather than just using the member variable.

  3. In my program the sender object should not be known at all to the clients. It’s hard to explain what I am doing but basically I have a class with an internal constructor within a library that is used by two other classes also within that library. My client classes are subscribing to events from those two classes but the events are originally invoked from this internal class that clients should not have any knowledge of.

  4. It is confusing to clients of the event handler. Libraries should be simple to understand and in my case, there is no reason to ever use the sender variable. None. Then why include it?

That being said, why does Microsoft indicate that event handlers should follow these guidelines? Isn’t it not always the best choice?

EDIT: Thanks for the replies everyone. I’ve decided to go with the majority and use EventHandler<T> for all my events in this library.

  • 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-25T19:57:47+00:00Added an answer on May 25, 2026 at 7:57 pm

    I think the reason for the pattern is to enforce some consistency. The sender parameter allows re-use of a single handler for multiple publishers (buttons, tables).

    To address your points:

    1) simply don’t use it. That is common and doesn’t really hurt any good practice.

    2) that’s OK, again ignore the sender

    3) is in total contradiction of what you said under 2) …
    And for the rest it is the same as 1). You could even consider passing null as sender.

    4) “then why include it” – there are other use cases that do require the sender.


    But do note this is just a guideline for libraries confirming to the BCL.
    Your case sounds more like a specific application (not a library) so feel free to use any parameter scheme you like. The compiler won’t complain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading this class BitmapFactory I noticed that almost all methods inside are static.
Thanks for reading. I've noticed that if I have a page that has one
I was reading on this page and it says dynamic_cast can be used only
Reading this page , it says: ...the URI in a PUT request identifies the
I was reading this page and I found the following statement: MVC in Java
I'm reading a web page using HttpClient like this: httpclient = new DefaultHttpClient(); httpget
After reading this article on thedailywtf.com, I'm not sure that I really got the
First of all, I have some time reading this page and I find very
And thanks in advance fro reading this. I am creating a page where the
Reading this page http://code.google.com/p/closure-stylesheets/ , I can't seem to find any documentation explaining how

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.