NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

8.1.6 Event handling

Methods can declaratively handle events raised by objects in non-shared data members. To handle an event, a method declaration specifies the Handles keyword and references the name of the event. The name of the event must be the name of an event member of a non-shared data member in the method's containing type, although the event itself may be shared. A method's accessibility has no effect on its ability to handle events.

For a handler to be valid, the handled event's parameter types must exactly match those of the event handler. A single member can handle multiple matching events. The data member that raises the event must be declared with the WithEvents modifier, otherwise an error results.

A type inherits all event handlers provided by its base type. A derived type cannot in any way alter the event mappings it inherits from its base types, but when an event method is handled by a overridable method, it is possible for derived types to override the overridable method and alter the handling of the event. Also note that if a type does not handle events raised by a WithEvents data member, then it is not possible for any derived class to handle the event.

HandlesClause ::= [ Handles EventMemberNameList ]
EventMemberNameList ::=
 EventMemberName |
 EventMemberNameList , EventMemberName