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!

9.6.2 AddHandler and RemoveHandler statements

Although most event handlers are automatically hooked up through WithEvents data members, it may be necessary to dynamically add and remove event handlers at runtime. The AddHandler and RemoveHandler statements do this.

Each statement takes two parameters: an event expression and an expression that must evaluate to a delegate instance of the appropriate type for the event hookup. Given an event E, the statement either calls the relevant add_E or remove_E method on the instance to add or remove the delegate as a handler for the event. The parameters are always evaluated left to right at runtime.

AddHandlerStatement ::= AddHandler HandlerArguments StatementTerminator
RemoveHandlerStatement ::= RemoveHandler HandlerArguments StatementTerminator
HandlerArguments ::= EventExpression , ArgumentExpression