RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplicationEvents.OnIdle Event

Occurs when an application becomes idle.

Pascal
property OnIdle: TIdleEvent;
C++
__property TIdleEvent OnIdle;

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. 

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.

Note: Call the CancelDispatch method from an OnIdle event handler to prevent the application from forwarding the event to any other application events objects.
 

C++ Examples: 

 

/*
This example requires a TApplicationEvents and a TListBox
in the form.  Select the TApplicationEvents, double click
on 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.
*/
void __fastcall TAppEventForm::ApplicationEventsIdle(TObject *Sender,
      bool &Done)
{
    lbIdle->Items->Add("Event OnIdle");
}

 

Delphi Examples: 

{
This example requires a TApplicationEvents and a TListBox
in the form.  Select the TApplicationEvents, double click
on 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;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!