Handling Application Events: OnIdle, OnThreadException, OnThreadExit