All operations on displayed CAPI elements need to be in the thread (that is, the
mp:process
) that runs their interface. On some platforms,
display
and
contain
make a new thread. On Cocoa, all interfaces run in a single thread.
In most cases this issue does not arise, because CAPI callbacks are run in the correct thread. However, if your code needs to communicate with a CAPI window from a random thread, it should use
execute-with-interface
,
execute-with-interface-if-alive
,
apply-in-pane-process
or
apply-in-pane-process-if-alive
to send the function to the correct thread.
This is why the brief interactive examples in this manual generally use
execute-with-interface
or
apply-in-pane-process
when modifying a displayed CAPI element. In contrast, the demo example in Connecting an interface to an application is modified only by callbacks which run in the demo interface's own process, and so there is no need to use
execute-with-interface
or
apply-in-pane-process
.
CAPI User Guide (Macintosh version) - 30 Aug 2011