Larry,
The sender is the object raising the event, if the handler of the event ever
checked who the sender was, sending Nothing would cause an exception or
"worse" require the handler to check for nothing then check who the sender
was. Remember you have no "real" control over who may handle your event.
EventArgs.Empty "Represents an event with no event data".
http://msdn.microsoft.com/library/de...EmptyTopic.asp
I am suggesting using EventArgs.Empty instead of New EventArgs when using
RaiseEvent on an event you have defined, not calling a specific handler
directly in your code.
I don't see it explicitly stated in the Guidelines, however I would not send
nothing for EventArgs either, as I am not in control of the code that
handles that event, it may attempt to access the EventArgs, and should not
be required to check for Null. EventArgs.Empty is effectively an
implementation of a Null Object or Special Case Pattern.
http://msdn.microsoft.com/library/de...Guidelines.asp http://msdn.microsoft.com/library/de...Guidelines.asp http://www.martinfowler.com/eaaCatalog/specialCase.html
In other words if you always send valid values for both sender & eventargs,
then the event handlers can simply use the values if they want, they don't
need to be littered with code to check to see if either is Nothing.
Hope this helps
Jay
"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote
I normally implement "Empty" as a shared readonly field or property.
Public Shared Readonly Empty As New myValue
The Empty property is most useful when you have an immutable class or
structure. One where all the instance fields are readonly. Such as
EventArgs.Empty. You can then use the class where you need an object, but
that object has no meaningful value, for example when you raise a lot of
events, its better to pass EventArgs.Empty rather then creating a new
"empty" EventArgs object... (a lot of empty objects can hurt
performance).
How about just passing Nothing as either argument (Sender and/or
EventArgs)
???
LFS