This example requires a TApplicationEvents and a TListBox on the form. Select the TApplicationEvents, double-click the OnIdle event and add the following code to the handler. The OnIdle event handler is used to perform special processing when an application is idle. An application is idle when it is not processing code.
procedure TMainForm.ApplicationEventsIdle(Sender: TObject; var Done: Boolean); begin lbIdle.Items.Add('Event OnIdle'); end;