To see how threads work, you can use the functions that are already registered in the PlatformFunctions dictionary. Then, choose the coroutineCallWith: message that takes the number of arguments that your external function needs.
Let's try a couple of examples, with and without using threads. The scripts you need to write will vary by platform.
(PlatformFunctions at: 'DosBeep') callWith: 440 with: 3000.
(PlatformFunctions at: 'Beep') callWith: 440 with: 3000.
| context | context := CgDisplay default handle. (PlatformFunctions at: 'XBell') callWith: context with: 50.
The callWith: message runs the beep process on the main VisualAge thread, causing all other processing to stop until the beep function is complete. Notice that while this example is running, if you move your mouse pointer outside the System Transcript, it remains a busy pointer, and you cannot interact with other windows.
To run the beep function on another thread, and free the main VisualAge thread to continue processing, use the coroutineCallWith:with: message.
(PlatformFunctions at: 'DosBeep') coroutineCallWith: 440 with: 3000.
| context | context := CgDisplay default handle. (PlatformFunctions at: 'XBell') coroutineCallWith: context with: 50.
Notice that while this example is running, you can move your mouse pointer outside the System Transcript and interact with other windows.