FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Background Processor
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Background Processor
Posted: Tue Nov 24, 2015 11:37 PM

My update system runs every 3 hours. In Windows, I use this to control the intervals without a lot of CPU demand:

DEFINE TIMER oTmr INTERVAL 900000 OF oWnd ;
ACTION IF( ElapTime( cStart, Time()) >= "03:00:00", RunUpdater(), )
ACTIVATE TIMER oTmr

Defining a timer requires a Window, so I simply replace it with a DO WHILE .t. loop. However, I only want it to process ElapTime( ) after the interval has passed.
I was looking for the equivalent of the INTERVAL 900000 used in defining the timer, but don't exactly see one.

The routine is built in xHarbour ( commercial ) and I am doing it as a non-GUI app.

Any suggestions for a timer that won't constantly eat away at the CPU ? I thought about Seconds( ) but that is a pretty constant call. Trying to remember back to the old DOS days ...

Thanks for your input.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Background Processor
Posted: Wed Nov 25, 2015 12:00 AM

how about HB_idleSleep( <nTime> )

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Background Processor
Posted: Wed Nov 25, 2015 04:02 AM

Is it specific to the application or generic to the os ?

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Background Processor
Posted: Wed Nov 25, 2015 08:25 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Background Processor
Posted: Wed Nov 25, 2015 10:13 AM

You are satisfied with the functionality of Timer but the only objection to use is that it requires a Window to be activated. Probably because you want this in a program which does not do any screen i/o, eg: Service or a Scheduled Task.

You can still use a window but activate it hidden,
DEFINE WINDOW oWnd
<other code>
ACTIVATE WINDOW oWnd HIDDEN

Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Background Processor
Posted: Wed Nov 25, 2015 07:15 PM
OK ... so I built the .exe and it will execute.

However, when I try to activate it as a service I get the error:

Error 1053 Service did not respond in a timely fashion

So ... this brings us back to the request for a sample of code on how to build a program that acts as a service. What do I need to add to get past the error above ?

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion