See EventDrivenProgramming.