N
news-server.san.rr.com
I have a class that defines a *static* event:
| public static event FubarEventHandler FubarAdded;
This event is raised in public static methods, such as:
| public static void AddFubar(...)
| {
| ...
|
| // Advise that a Fubar was added to the master Fubar list
| if (FubarAdded != null)
| FubarAdded(null, new FubarEventArgs(fubarObject));
|
| ...
| }
Note that the 'sender' parameter is null. In a static method, I don't have
an instance, so I can't pass in 'this', and it seems silly for me to require
the caller to pass in it's 'this' reference...
I suppose I could pass in a reference to the static collection member that
contains the list of Fubar objects, but that seems pretty meaningless.
Is there a typical practice here? Is passing 'null' for sender OK in this
situation?
Thanks in advance.
-Scott
| public static event FubarEventHandler FubarAdded;
This event is raised in public static methods, such as:
| public static void AddFubar(...)
| {
| ...
|
| // Advise that a Fubar was added to the master Fubar list
| if (FubarAdded != null)
| FubarAdded(null, new FubarEventArgs(fubarObject));
|
| ...
| }
Note that the 'sender' parameter is null. In a static method, I don't have
an instance, so I can't pass in 'this', and it seems silly for me to require
the caller to pass in it's 'this' reference...
I suppose I could pass in a reference to the static collection member that
contains the list of Fubar objects, but that seems pretty meaningless.
Is there a typical practice here? Is passing 'null' for sender OK in this
situation?
Thanks in advance.
-Scott