G
Guest
So, here is a wierd question that we have been discussing for a bit now.
Does an event fire even though nothing is subscribed to listen to the event?
For instance, does the Click event of a button fire even though nothing is
subscribed to listen to the event.
The answer is NO in a traditional Publisher/Subscriber design pattern (at
least I think it is).
I have stated that if nothing is subscribed, then the event never gets
raised. I would stand by that statement until another developer turned on
Spy++ and it looks like some Windows files are responding to events on a form
ie. Click, MouseOver, etc...). My response to that is Windows must subscribe
to the .NET event so it knows how to do things, like draw a depressed button
when the button gets clicked.
If this is not the case, then I would ask "When creating a custom event, why
does one need to test the event for null before raising the event?" I know
the reason - cuz the delegate is not created. But do standard events (ie.
Click, MouseOver, etc...) not follow the same rule that custom events do?
I know this sounds like a strange discussion and it is like "Does a falling
tree make a sound if no one is around?".
Just curious is anyone can shed some light. I cannot find anything on the
internet that gets into a discussion about this (probably cuz no one cares).
Thanks in advance...
Does an event fire even though nothing is subscribed to listen to the event?
For instance, does the Click event of a button fire even though nothing is
subscribed to listen to the event.
The answer is NO in a traditional Publisher/Subscriber design pattern (at
least I think it is).
I have stated that if nothing is subscribed, then the event never gets
raised. I would stand by that statement until another developer turned on
Spy++ and it looks like some Windows files are responding to events on a form
ie. Click, MouseOver, etc...). My response to that is Windows must subscribe
to the .NET event so it knows how to do things, like draw a depressed button
when the button gets clicked.
If this is not the case, then I would ask "When creating a custom event, why
does one need to test the event for null before raising the event?" I know
the reason - cuz the delegate is not created. But do standard events (ie.
Click, MouseOver, etc...) not follow the same rule that custom events do?
I know this sounds like a strange discussion and it is like "Does a falling
tree make a sound if no one is around?".
Just curious is anyone can shed some light. I cannot find anything on the
internet that gets into a discussion about this (probably cuz no one cares).
Thanks in advance...