Board index » delphi » Launch a task at midnight

Launch a task at midnight

Hi,

Can somebody tell me how to launch a task at midnight in my Delphi
application (generate an event for example) without affecting the rest of
the process ?

Has somebody a sample source code to make this without a "repeat....until"
or a TTimer ?

Thanks.

 

Re:Launch a task at midnight


If I understand you correctly you want your Delphi program to launch a task
at a particular time but you do not want the program to sit in a loop
testing for the time, nor do you want to use a tTimer to trigger the event?
Does this also mean that you don't want to use the Win API encapsulated by
tTimer? Presuming this, I guess you'll have to sprinkle calls to a
CheckAndLaunch procedure throughout your program. The procedure would check
the time and when appropriate launch the task. Its an awfully messy way to
do it and you would be much better off using a timer and setting its
interval to 86400000 - Trunc (86400000 * Time). Better yet, why not simply
add the task to the Windows task scheduler?

"Manuel De Carvalho" <mdecarva...@ametis-tm.com> wrote in message
news:835nq1$ga$1@wanadoo.fr...

Quote
> Hi,

> Can somebody tell me how to launch a task at midnight in my Delphi
> application (generate an event for example) without affecting the rest of
> the process ?

> Has somebody a sample source code to make this without a "repeat....until"
> or a TTimer ?

> Thanks.

Re:Launch a task at midnight


You can also consider to use WinAt to schedule your  application. It would be
more easier!

Manuel De Carvalho

Quote
> Hi,

> Can somebody tell me how to launch a task at midnight in my Delphi
> application (generate an event for example) without affecting the rest of
> the process ?

> Has somebody a sample source code to make this without a "repeat....until"
> or a TTimer ?

> Thanks.

--
  Ming-Cheng Chen ()
  Associate Researcher
  ChungHwa Telecom Co., Telecommunication Lab.
  Electronic Toll Collection for Highway Project
  Tel: 886-3-4245996     Fax: 886-3-4245194
  E-mail: yoyoc...@ms.chttl.com.tw
  http://www.ham.com.tw/~bm4acd

Re:Launch a task at midnight


i'm not sure if you have much choice but to use a timer that checks the
time every second. . you can always use application.handlemessages (i think)
to yield to the OS so you don't take up 100% cpu time...   if you come
up with a good way to do it, let me know, i'd be interested as well,
but the AT command is always good.
Quote
Yoyo Chen wrote:
> You can also consider to use WinAt to schedule your  application. It would be
> more easier!

> Manuel De Carvalho ?g1D?G

> > Hi,

> > Can somebody tell me how to launch a task at midnight in my Delphi
> > application (generate an event for example) without affecting the rest of
> > the process ?

> > Has somebody a sample source code to make this without a "repeat....until"
> > or a TTimer ?

> > Thanks.

> --
>   Ming-Cheng Chen (3??)
>   Associate Researcher
>   ChungHwa Telecom Co., Telecommunication Lab.
>   Electronic Toll Collection for Highway Project
>   Tel: 886-3-4245996     Fax: 886-3-4245194
>   E-mail: yoyoc...@ms.chttl.com.tw
>   http://www.ham.com.tw/~bm4acd

Re:Launch a task at midnight


U?ytkownik Neel Parikh <neel_par...@iname.com> w wiadomooci do grup
dyskusyjnych napisa3:3859C77E.95CE...@iname.com...

Quote
> i'm not sure if you have much choice but to use a timer that checks the
> time every second. .

first minute after start application - every second
when you know when the minute starts you set second Ttimer - that checks
every minute. First timer set off.

Dafi

Re:Launch a task at midnight


const MillisecondsInADay = 86400000;     // 24hrs * 60min * 60sec *
1000msec;

aTimer.Interval := Trunc ((EncodeTime (23, 59, 59, 999)  - Time) *
MillisecondsInADay);

aTimer will fire around midnight.

Quote
"Dafi" <d...@kki.net.pl> wrote in message

news:2K164.61030$Oo3.1390290@news.tpnet.pl...
Quote

> U?ytkownik Neel Parikh <neel_par...@iname.com> w wiadomooci do grup
> dyskusyjnych napisa3:3859C77E.95CE...@iname.com...
> > i'm not sure if you have much choice but to use a timer that checks the
> > time every second. .

> first minute after start application - every second
> when you know when the minute starts you set second Ttimer - that checks
> every minute. First timer set off.

> Dafi

Re:Launch a task at midnight


Why not a TTimer?
You can also look at sleep, but since it stop the thread, put in a
differenthread id there is any interface that may need uptape before
midnight.
Consider the at command from win NT it's esaier if it's for you ron
use and it's not for "almost every day" use

On Tue, 14 Dec 1999 16:30:14 +0100, "Manuel De Carvalho"

Quote
<mdecarva...@ametis-tm.com> wrote:
>Hi,

>Can somebody tell me how to launch a task at midnight in my Delphi
>application (generate an event for example) without affecting the rest of
>the process ?

>Has somebody a sample source code to make this without a "repeat....until"
>or a TTimer ?

>Thanks.

Re:Launch a task at midnight


I believe Application.ProcessMessages is what
you're looking for there...

Jeremy Nelson

Quote
> time every second. . you can always use

application.handlemessages (i think)
Quote

> Yoyo Chen wrote:

> > You can also consider to use WinAt to

schedule your  application. It would be
Quote
> > easier!

> > > Hi,

> > > Can somebody tell me how to launch a task

at midnight in my Delphi
Quote
> > > application (generate an event for example)

without affecting the rest of
Quote
> > > the process ?

> > > Has somebody a sample source code to make

this without a "repeat....until"

Quote
> > > or a TTimer ?

> > > Thanks.

> > --
> >   Ming-Cheng Chen (3??)
> >   Associate Researcher
> >   ChungHwa Telecom Co., Telecommunication Lab.
> >   Electronic Toll Collection for Highway
Project
> >   Tel: 886-3-4245996     Fax: 886-3-4245194
> >   E-mail: yoyoc...@ms.chttl.com.tw
> >   http://www.ham.com.tw/~bm4acd

Sent via Deja.com http://www.deja.com/
Before you buy.

Other Threads