Methods: asynchronous vs. synchronous
Methods are subroutines you write, but they aren’t something you call from your program. Rather, Toolkit calls them automatically when certain events take place. Some methods are called immediately when a given event takes place. Others aren’t called until Toolkit is ready. Methods are documented throughout this manual, but this appendix discusses issues common to types of methods.
Asynchronous methods are called as soon as their events take place. For example, if you’ve written an arrive method for a field, the arrive method is called immediately when the user arrives on the field. Asynchronous methods include the following:
- Arrive, leave, change, edit format, and display input methods
- Arrive, leave, double-click, and load list methods
- Toolbar button methods
- %UWNDEVENTS_METHOD methods (including AX_ methods)
- The following E_METHOD environment methods: D_METH_APPCLOSE, D_METH_CHKFLD, D_METH_DSPFLD, D_METH_EDTDSP, D_METH_ENTRST, D_METH_APPMOVE, D_METH_APPSIZE, and D_METH_APPSTATE
Within asynchronous methods on Windows, it’s best to avoid doing any user-interactive processing (with the possible exception of a highly conditional message box). Asynchronous methods need to be self contained and they need to execute quickly because they are triggered by Windows events, so it is difficult to determine exactly when the method might be used in relation to your code and Toolkit code. See Notes on input methods for more restrictions.
Synchronous methods are not called when their events take place, but are deferred until Toolkit is ready to call them. For example, if you write a drill method for an input field, the method will not be called immediately when the user clicks the drilldown button or selects the drilldown menu entry. Instead, if the input field is in focus, the leave method for the field is first invoked, then the drill method is called. Synchronous methods include the following:
- Hyperlink and drilldown input methods
- The following E_METHOD environment methods: D_METH_UTILS, D_METH_HELP, D_METH_FKEY, D_METH_CENTURY, and D_METH_SCRIPTERR
- Methods invoked as a result of %M_SIGNAL
- Tab set methods
- Composite window methods