All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries

execute-with-interface-if-alive Function


Executes a function in the event process of a given interface if it is alive.




execute-with-interface-if-alive interface function &rest args => alivep

A function designator.
Arguments passed to function.
A boolean.

The function execute-with-interface-if-alive applies the function function to the arguments args in the process of the interface interface, if the interface is "alive". An interface become alive during the creation process before interface-display is called (and before display returns). It stops being alive once it is destroyed, either programmatically or by the user.

If interface is not alive, function is not applied. This is in contrast to execute-with-interface, which in this case applies the function in the current process.

The return value alivep is true if interface was alive while execute-with-interface-if-alive executed. It does not guarantee that function is going to be called.

execute-with-interface-if-alive is useful for automatic updating of interfaces that may be destroyed by the user, where the update is redundant if the interface is not alive.

  1. The return value is useful for checking whether the interface has gone away (for example closed by the user), in which case the caller may want to do something, most typically stop calling execute-with-interface-if-alive on the dead interface. It should be checked only when the caller knows that the interface is already displayed (display returned, or interface-display was called on it), otherwise it may be nil because it is not displayed yet.
  2. All accesses (reads as well as writes) on a CAPI interface and its sub-elements should be performed in the interface process. Using execute-with-interface-if-alive is one way of ensuring this.
See also

4.1 The correct thread for CAPI operations
7 Programming with CAPI Windows

CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:27