Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12116
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to write a browser based timer |
| Date | 2012-02-23 16:38 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <bnmdk7dbd04crei6qnaip7mosmesh8vkc8@4ax.com> (permalink) |
| References | (1 earlier) <a44b4295-4c38-40c3-bc86-f63bd24d7720@b23g2000yqn.googlegroups.com> <ht38k7pv0rr3vrinoj674dg70v5iic6tsq@4ax.com> <XnsA000F0C4BFBD3eejj99@194.109.133.133> <3bf207fd-3d2f-40ab-95e7-9a1ed5a2ffd2@vh10g2000pbc.googlegroups.com> <6Zcx$FIPQpRPFwYj@invalid.uk.co.demon.merlyn.invalid> |
On Thu, 23 Feb 2012 19:31:27 +0000, Dr J R Stockton
<reply1208@merlyn.demon.co.uk> wrote:
[snip]
>The answer, IMHO, is to use setInterval. I'm not sure what happens if
>one calls for an interval of one second and, after a while, keeps the
>CPU very busy for a few seconds - does one get a burst of late
>setInterval handler calls, or are some lost? And what if, after
>starting with setInterval, the machine is put into standby for a while?
>But with setInterval, delays of substantially under a second in making
>one handler call do not accumulate, as they would with simple repeated
>setTimeout (Func, /const/)
I suspect that the next interval is set as part of the previous
one firing:
Catch that an interval has expired:
Set next interval.
Do what is supposed to be done with an fired interval.
>To allow as best one can for such possibilities, the OP should NOT count
>those handler calls for a measure of time, but should call new Date() to
>get the time in milliseconds, from which simple arithmetic will get the
>minutes, seconds, and maybe fractional part to display.
Quite.
>However, the valid objections to a wait loop along the lines of
> while (new Date()<EndTime) { ... }
>are fewer than commonly thought. A simple loop calculating the date of
>Gregorian Easter Sunday for a full cycle or more takes a significant
>while, but with at least some browsers the machine is still adequately
>responsive.
I do not agree. On a system doing only one thing (as far as the
user is concerned?), that may be fine, but with multiple things going,
no.
Sincerely,
Gene Wirchenko
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to write a browser based timer " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-21 15:50 -0500
Re: How to write a browser based timer Scott Sauyet <scott.sauyet@gmail.com> - 2012-02-21 13:04 -0800
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-21 13:45 -0800
Re: How to write a browser based timer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-21 22:40 +0000
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-21 15:04 -0800
Re: How to write a browser based timer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-21 23:27 +0000
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-21 16:08 -0800
Re: How to write a browser based timer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-22 15:41 +0000
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-22 09:19 -0800
Re: How to write a browser based timer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-22 21:55 +0000
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-22 15:01 -0800
Re: How to write a browser based timer RobG <rgqld@iinet.net.au> - 2012-02-21 18:18 -0800
Re: How to write a browser based timer Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-23 19:31 +0000
Re: How to write a browser based timer Gene Wirchenko <genew@ocis.net> - 2012-02-23 16:38 -0800
Re: How to write a browser based timer Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-25 20:29 +0000
Re: How to write a browser based timer "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-26 23:02 +0000
Re: How to write a browser based timer Dr J R Stockton <jrs@merlyn.demon.co.uk> - 2012-02-22 18:51 +0000
Re: How to write a browser based timer " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-23 10:23 -0500
Re: How to write a browser based timer Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-23 22:13 +0100
Re: How to write a browser based timer Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-24 09:41 +0100
csiph-web