EVENT

Declare an event

 

 

 

NSupported in Synergy .NET
PUBLIC event_mod EVENT event, @delegate

event_mod

(optional) One or more of the following event modifiers:

ABSTRACT

Must have a method implemented in a derived class of the same signature. Subclasses must implement this method.

NEW

Hide an inherited member of the same name.

OVERRIDE

Overrides the parent class’s virtual method that has the same method signature.

STATIC

Accessed without a reference object. The method can be executed even if the class that contains the method hasn’t been instantiated.

VIRTUAL

Can be overridden in a subclass.

event

The name of the event being declared.

delegate

A previously defined delegate to call when the event is raised. (See DELEGATE-ENDDELEGATE.)

Events are used extensively in Windows and Web Forms. An event enables you to tie a method that handles an event to the event itself (for example, a button click). When the event occurs, the event handling methods are executed for the method.

You can register an event handler to an accessible event from an instantiated .NET class using the ADDHANDLER statement. (See ADDHANDLER.) The first parameter to ADDHANDLER must be an accessible event, and the second parameter must be one of the following:

For example,

addhandler(var1.myevent, obj.myEventHandlingMethod)
myd, @MyDelegate
myd = new MyDelegate(obj.myEventHandlingMethod)
addhandler(var1.myevent, myd) 

The event must keep a list of all delegates to call when the event is raised. Delegates allow a function to be passed as a parameter value.

To trigger a declared event, use the RAISEEVENT statement. (See RAISEEVENT.)

To remove an event, use the REMOVEHANDLER statement. (See REMOVEHANDLER.)

See ADDHANDLER.