timer class : Handler(anyclass) setter
Description
Sets an instance of an user-defined class that have the handler method.
Syntax
instance.Handler = value
Arguments
Class | Description |
user-defined class | An instance of an user-defined class. |
Return value
None
Sample code
Suppose you have the following class definition.
1: | class handleA |
2: | open method void THandler(dictionary dic) |
3: | ... // event handler code. |
4: | endmethod |
5: | endclass |
6: | class handleB |
7: | open method void THandler(dictionary dic) |
8: | ... // event handler code. |
9: | endmethod |
10: | endclass |
Usage of the Handler setter is as follows.
1: | handleA ha = new handleA(); |
2: | handleB hb = new handleB(); |
3: | timer tim = new timer(ha, "THandler(dictionary)", 1000); // It sets the instance of the handleA class. |
4: | tim.Handler = hb; // It changes the instance to the handleB class. |
In the above code, Handler instances are different class, but these have the method with same signature, so it works fine.
Notes
None
Links for reference
None