使用TApplicationEven 的OnIdle事件处理:<br>Occurs when an application becomes idle.<br>type TIdleEvent = procedure (Sender: TObject; var Done: Boolean) of object;<br>property OnIdle: TIdleEvent;<br>Description<br>Write an OnIdle event handler to perform special processing when an application is idle. An application is idle when it is not processing code. For example, an application is idle when it is waiting for input from the user.<br>TIdleEvent has a Boolean parameter Done that is True by default. When Done is True, the Windows API WaitMessage function is called after OnIdle returns. WaitMessage yields control to other applications until a new message appears in the message queue of the application. When Done is False, the application does not yield control to other applications while it is not busy.<br>OnIdle is called only once, as the application transitions into an idle state. It is not called continuously unless Done is set to False. Applications that set Done to False consume an inordinate amount of CPU time, which affects overall system performance.<br><br>Note: Call the CancelDispatch method from an OnIdle event handler to prevent the application from forwarding the event to any other application events objects.