beginwithl
Programmer
hi
First I’d like to point out that I do understand how to use Events according to Net Framework guidelines, I just don’t understand the benefits of this Event pattern
From MSDN site:
"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. The type of
the "e" parameter should derive from the EventArgs class. For events that do not use any additional information, the .NET Framework has already defined an appropriate delegate type: EventHandler."
a) I don’t understand why it would be so much more useful for all the delegate types used for events to have the same first parameter, and having EventArgs or class derived from it as a second parameter?
b) Whatever the benefits may be, why would they out-weight the trouble of having to:
- write an additional code to put the desired arguments into an object ( of type derived from EventArgs ) that will be passed as an argument when event is fired
- write an additional code inside event handlers to extract
information from objects ( of types derived from EventArgs)
?
thank you
First I’d like to point out that I do understand how to use Events according to Net Framework guidelines, I just don’t understand the benefits of this Event pattern
From MSDN site:
"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. The type of
the "e" parameter should derive from the EventArgs class. For events that do not use any additional information, the .NET Framework has already defined an appropriate delegate type: EventHandler."
a) I don’t understand why it would be so much more useful for all the delegate types used for events to have the same first parameter, and having EventArgs or class derived from it as a second parameter?
b) Whatever the benefits may be, why would they out-weight the trouble of having to:
- write an additional code to put the desired arguments into an object ( of type derived from EventArgs ) that will be passed as an argument when event is fired
- write an additional code inside event handlers to extract
information from objects ( of types derived from EventArgs)
?
thank you