Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Using the Application's OnIdle Event.


How do I have my application perform work when the computer is idle?   

    You can create an OnIdle event to be called whenever your application is waiting for messages to be processed. Simply declare the event handler procedure in the private section of the forms declaration:

    { Private declarations }
    procedure IdleEventHandler(Sender: TObject; var Done: Boolean);
    In then implementation section, define the procedure:
    procedure TForm .IdleEventHandler(Sender: TObject;
      var Done: Boolean);
    begin
     {Do a small bit of work here}
      Done := false;
    end;
    Then assign the Application's OnIdle event to point to your new procedure(You may do this whereever you like, but a good place would be the Forms OnCreate method):
    Application.OnIdle := IdleEventHandler;
    OnIdle is called only once, as the application transitions into an idle state. It is not called continuiously unless Done is set to False If Done is False, WaitMessage is not called. Applications that set Done to False consume an inordinate amount of CPU time that affects overall system performance.
    ou can set the boolean variable "done" to true when you want to stop the event handler from executing.
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use