How to process the .NET events
To process the .Net events, you must:
1. Find the event.
The event is a member of a .NET class. This member has a name and a type. The type defines the type of the handler that can be associated with the event. The name is used to find two methods:
- "add_<Event name>"
- "remove_<Event name>"
These two methods are used to associate and dissociate one or more handlers with/from an event. The type of the parameter for these two methods is the name of the handler type.
Example: The OwnEvent class contains a MyEvent event whose type is EventHandler<MyEventArgument>.
2. Retrieve a handler.
A handler can be retrieved with DotNetDelegate:
- The first parameter is the name of the WLanguage procedure
- The second parameter is the name of the class of the handler type. This name can be retrieved by the name of the type of parameters of "add_xxx" and "remove_xxx" methods.
Example: The WLanguage procedure has the following format:
PROCÉDURE MyHandler(src, args)
src is a .NET object of OwnEvent type, args is a .NET object of MyEventArgument type
3. Associate the handler with the event
To associate the handler with the event, all you have to do is call the "add_<Event Name> method on the object that owns the event".
4. Trigger the event
In our example, the call to clOwn:Trigger triggers the event.
In the WLanguage procedure, you can:
- use the methods associated with the parameters of the procedure. However, the completion is not available.
- define a dynamic object and assign the requested parameter to it. The completion is available for the object.
These two methods are used in the detailed example.