Board index » delphi » Using time to close an app

Using time to close an app

Hi all

I need to develop an application that has to run just for let's say 45
minutes and then close.

What is the best way to do this.

I was thinking on using a Ttimer but I don't know if it's the best choice

any help

 

Re:Using time to close an app


Quote
Gildardo wrote:
> I need to develop an application that has to run just for let's say 45
> minutes and then close.

> What is the best way to do this.

> I was thinking on using a Ttimer but I don't know if it's the best choice

Something has to trigger you to wake up periodically and check to
see if it is time to shut down. Unless, of course, you're always
running, in which case you can just check every 100 times through
your loop. But nominally, you'd probably do fine with a TTimer.

Good luck.

Kurt

Re:Using time to close an app


On Mon, 24 Sep 2001 18:35:48 -0700, "Gildardo"

Quote
<Gilda...@hmo.megared.net.mx> wrote:

>I was thinking on using a Ttimer but I don't know if it's the best choice

Sure, why not?  Set the timer's interval to

const
  FortyFiveMinutes = 45 * (1/24/60);

And them

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Interval := Round(FortyFiveMinutes) * 1000;
   Timer1.Enabled := True;
end;

And in the OnTimer --

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Close;
end;

Nick Hodges - TeamB
HardThink, Inc.
Please always follow the newsgroup guidelines --
http://www.borland.com/newsgroups

Re:Using time to close an app


Thank you for the info.

Gildardo.

Re:Using time to close an app


Quote

> procedure TForm1.FormCreate(Sender: TObject);
> begin
>   Timer1.Interval := Round(FortyFiveMinutes) * 1000;

   if I use the  function to round the constant   FortyFiveMinutes = 45 *
(1/24/60);
   it returns 0.  the constant value is 0.03125 is this ok?? something i'm
missing
 could I just give 2700000 to the interval (45 in milliseconds I think)
Quote
>    Timer1.Enabled := True;
> end;

Re:Using time to close an app


Quote
Gildardo wrote:
>    if I use the  function to round the constant   FortyFiveMinutes = 45 *
> (1/24/60);
>    it returns 0.  the constant value is 0.03125 is this ok?? something i'm
> missing
>  could I just give 2700000 to the interval (45 in milliseconds I think)

Nick's expression for the interval was a bit odd. The correct
calculation would be 45 * 1000 * 60 = 2700000 as you noted.

Good luck.

Kurt

Other Threads