DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

How can terminate my application if idle for 5 minutes?

Question:

How can terminate my application if idle for 5 minutes?

Answer:

This should get you started. For testing I set the timer to 10 seconds.

unit Unit1;
 
 interface
 
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   ExtCtrls;
 
 type
   TForm1 = class(TForm)
     Timer1: TTimer;
     procedure FormCreate(Sender: TObject);
     procedure Timer1Timer(Sender: TObject);
   private
     { Private declarations }
     procedure DoOnIdle(Sender: TObject; var Done:
 Boolean);
   public
     { Public declarations }
   end;
 
 var
   Form1: TForm1;
 
 implementation
 
 {$R *.DFM}
 
 procedure TForm1.DoOnIdle(Sender: TObject; var
 Done: Boolean);
 begin
   Timer1.Enabled := False;
   Timer1.Enabled := True;
 end;
 
 procedure TForm1.FormCreate(Sender: TObject);
 begin
   Application.OnIdle := DoOnIdle;
 end;
 
 procedure TForm1.Timer1Timer(Sender: TObject);
 begin
   ShowMessage('Shutdown!');
 end;
 
 end.

Generated 0:02:08 on Oct 17, 2019