User's Guide


Using threads

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.

OS/2 icon
To cause a beep to sound on OS/2 with the frequency of 440 hertz and a duration of 3 seconds, use Execute to evaluate the following script from the System Transcript:
(PlatformFunctions at: 'DosBeep')
    callWith: 440 with: 3000.

Windows icon
To cause a beep to sound on Windows with the frequency of 440 hertz and a duration of 3 seconds, evaluate the following script from the System Transcript:
(PlatformFunctions at: 'Beep')
    callWith: 440 with: 3000.

UNIX icon
To cause a beep to sound on UNIX systems, evaluate the following script from the System Transcript:
| 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.

OS/2 icon
For OS/2, evaluate the following script from the System Transcript:
(PlatformFunctions at: 'DosBeep')
    coroutineCallWith: 440 with: 3000.

UNIX icon
For UNIX systems, execute the following script from the System Transcript:
| 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.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]