I actually am quite confused why, when designing the . Net Framework v2, MS didn't provide an EventHandler just the way you described - with the TSender and TEventArgs as both generic arguments. (In v1 and v1.1, since they didn't have generics, I completely understand why they didn't make thousands of extra delegate types to handle all the possible events.) If I remember properly, you can still use a generalized handler to listen to a more specific event.
I actually am quite confused why, when designing the . Net Framework v2, MS didn't provide an EventHandler just the way you described - with the TSender and TEventArgs as both generic arguments. (In v1 and v1.1, since they didn't have generics, I completely understand why they didn't make thousands of extra delegate types to handle all the possible events.) If I remember properly, you can still use a generalized handler to listen to a more specific event: public event EventHandler MouseDown; private void ObservingMethod(object sender, EventArgs e) { } MouseDown += new EventHandler(ObservingMethod); Since you're not exposing the observer to the observable, I don't see how this could be a problem; you're just preventing the need to do type-checking 'just in case' once you get to the event handler.
I think it'd be a fantastic practice, although a bit non-standard since MS decided not to include it. As noted in my comment above, I would prefer to see the following definition of EventHandler, so that you really could always use a very generalized handler method, as my code sample: public delegate void EventHandler(TSender sender, TEventArgs e) where TEventArgs : EventArgs.
Probably because most of those events are declared in a base class (Control - ButtonBase - ...) and therefor wouldn't have the Button class as sender. (and no covariance then yet ;) – Stormenet Jul 13 '10 at 12:19 That's fair, but even using the most restrictive object, even if it was an abstract base class or even an interface that it knew about would be helpful. For instance, having quick access without casting for a CaptureMouse call from a MouseDown event.
And, since the explicit delegate wrapping works (as above, without generics), we'd still be able to use a generalized event handler. – Matt DeKrey Jul 14 '10 at 13:38.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.