摘要:
A method and system for providing event-response and monitoring capabilities to a pseudocode program operating in a message or event-based operating environment. The method and system allow the pseudocode program to asynchronously respond to events via one or more trap routines located in the pseudocode program. The method and system also allow the pseudocode program to synchronously monitor events and receive parameters from operating system routines via callback routines located in the pseudocode program. The system includes an execution engine for executing instructions of the pseudocode program. An event-response routine in the pseudocode program includes instructions for responding to the event. An event-response dispatcher is adapted to receive information identifying the event-response routine, save the execution state of the execution engine, cause the execution engine to execute the event-response routine, and restore the execution state of the execution engine that existed before the event-response routine was executed. A transfer routine accessible in response to a call triggered by the event accesses the event-response dispatcher, passes information identifying the event-response routine to the event-response dispatcher, and returns control to the execution engine after the event-response dispatcher restores the state of the execution engine and returns to the transfer routine.