Background Operation

During its initialization sequence, the emulator should hook the keyboard interrupt to allow it to scan for the hot key sequence that it uses to switch between foreground and background operation.

When the emulator has completed its initialization and wishes to go resident, it must call CMDGoTSR passing the address of a procedure that is used to start a background thread of execution. The call executes an MS-DOS TSR call to force the emulator to be resident, and will never return control to the emulator.

The background thread can be used to perform any work items that are required (such as processing messages received from the local node, initiating a file transfer, and so on), but the emulator must not write any output to the screen while in background mode.

When the emulator detects a hot key sequence that commands it to return to the foreground, it must first call CMDStopFG to suspend the current foreground thread and gain control of the screen area. If this call returns a nonzero value, the foreground thread has been stopped within MS-DOS. In this case, the emulator must not switch into the foreground, and should restart the foreground thread.