1. A method in a data processing system for generating an event handling patch table for a program, the data processing system including a compiler for compiling the program and a memory, comprising the steps of: selecting at least one location in a function of the program to perform event handling; at compile-time, generating a patch table including substitution code for event handling at the selected location during execution of compiled program code of the function, wherein the generating includes recording in the patch table the at least one selected location and a corresponding event handler that is not part of the program unless an event of the corresponding event handler is triggered; and storing the patch table in association with the compiled program code; wherein upon detecting the occurrence of the event to be handled at run-time, the patch table is consulted to patch the substitution code into the compiled program code to call the corresponding event handler at the at least one selected location free of polling.