Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thanks for pointing me to your SO question. It's very interesting. I still don't understand why it's so important that the sender is mandatory. Most of the time I don't care about the sender. Is it just some arbitrary MS rule? Commented Apr 13, 2011 at 11:00
  • No, of course you can declare your delegates however you like. It's .NET policy to always include the sender, and it's not entirely a bad idea at that. Commented Apr 13, 2011 at 11:04
  • @Neil: I understand that it use useful sometimes, but I don't get the policy of always doing it - especially since MS recommend doing events their way. One of the things I really like about events is the ability to decouple classes. If I'm including the object, then it's coupled back up again. If it's just a CLS compliance thing then I can live with that. Commented Apr 13, 2011 at 11:46
  • It's coupled back up again only if you use the sender object, otherwise it doesn't matter what gets put as the value of sender since you don't use it. Dependency exists only if you need there to be a dependency. I see where you're coming from, and if object sender disappeared from all code from any server on the planet, I wouldn't stay up nights. Commented Apr 13, 2011 at 12:19
  • Yes, you can send 'null' as the sender if you really want... But, by including the Sender, the event handler itself could unsubscribe if it wanted to. Overall, though, I would say that knowing the source of the event is usually pretty important. Commented Apr 13, 2011 at 23:19