🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14951

Re: Does TTimer interval including Processing Time?

#14951
From: Bruce Salzman
Date: Wed, 23 Jul 2003 04:37
35 lines
2584 bytes
"Phuoc Can HUA" <home}a+t{huaonline.com> wrote in message
news:oprsqp0tqnbq7az6@newsgroups.borland.com...
> Q1: If the interval is 50ms and the routine needs 10ms will the routine be
> called every 60ms?

No, the timer runs independently of your code. The processing time is not
included.

> If that's not the case, i.e. as long as the processing time less than the
> interval I can rely on the timer(?)

Depends on how you are invoking the timer. If you are using a WM_TIMER
message (SetTimer), then it is just pulled out of your windows application
message queue like any other message. It won't be processed until your
message loop runs. If your program is busy doing something else when
WM_TIMER arrives, your timer routine will be delayed. Additionally, WM_TIMER
messages are notoriously innacurate.

> Let's say I've got 2 routines for a timer event, one is 10ms and 2nd one
> 20-45ms, i.e. sometimes it will exceed the timer interval of 50ms. The 2nd
> routine is only called every 5th time of the 1st one.
> Q2: If I define a 2nd timer of 250ms for the 2nd routine will it increase
> the accuracy of the timers?

Yes, that would be a better solution.

If you are worried about accuracy (and it sounds like you are), you need to
use the multi-media timer functions (see timeSetEvent) and use a callback
function. They are more accurate since the callback is invoked from an
independent thread (more like an interrupt). However, there is no really
precise, reliable timer event in windows. (quote: "Windows is not a RTOS.")

Regards,
Bruce
Technical Details
Message-ID: <3f1e10fb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <oprsqp0tqnbq7az6@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,354c421bf944414a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-22 21:39:30 PST
From: " Bruce Salzman" <bruce@nospam.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <oprsqp0tqnbq7az6@newsgroups.borland.com>
Subject: Re: Does TTimer interval including Processing Time?
Date: Tue, 22 Jul 2003 23:37:16 -0500
Lines: 37
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 24.94.238.27
Message-ID: <3f1e10fb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1058935035 24.94.238.27 (22 Jul 2003 21:37:15 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail