Question of reason for rule "return value void for event handling delegates"
-
Hi, lately I worked on some applications using the Model View Preseter Pattern combined with events with return values to refresh Gui controls. It works pretty good so I´m wondering why there is a convention saying events should have the return value 'void'. I would appreciate if someone could explain the reason for that rule... Thx in advance... Chamundi
-
Hi, lately I worked on some applications using the Model View Preseter Pattern combined with events with return values to refresh Gui controls. It works pretty good so I´m wondering why there is a convention saying events should have the return value 'void'. I would appreciate if someone could explain the reason for that rule... Thx in advance... Chamundi
http://msdn.microsoft.com/en-us/library/4b612y2s.aspx[^] An event is an association between a delegate and a member function (event handler) that responds to the triggering of the event and allows clients from any class to register methods that comply with the signature and return type of the underlying delegate. The delegate can have one or more associated methods that will be called when your code indicates that the event has occurred. An event in one program can be made available to other programs that target the .NET Framework common language runtime So in short, the delegate is a multicast delegate, and can have more than one method attached and this is basicly the reason that it must be void. Hope it makes sence :)
-
Hi, lately I worked on some applications using the Model View Preseter Pattern combined with events with return values to refresh Gui controls. It works pretty good so I´m wondering why there is a convention saying events should have the return value 'void'. I would appreciate if someone could explain the reason for that rule... Thx in advance... Chamundi
when more than one delegate is added to an event, they all get fired; which return value would you hope to get? :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
when more than one delegate is added to an event, they all get fired; which return value would you hope to get? :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
Thx for the quick answer...considering the multicast issue of delegates/events and the reusability of assemblies it makes sense using a void return value...
you're welcome. BTW: void is not a value, it is a type (or absence thereof, some would say). :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
you're welcome. BTW: void is not a value, it is a type (or absence thereof, some would say). :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.