Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12186
| From | Dr J R Stockton <reply1208@merlyn.demon.co.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to write a browser based timer |
| Date | 2012-02-25 20:29 +0000 |
| Organization | Home |
| Message-ID | <ZFo54AORSUSPFwUT@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | (2 earlier) <ht38k7pv0rr3vrinoj674dg70v5iic6tsq@4ax.com> <XnsA000F0C4BFBD3eejj99@194.109.133.133> <3bf207fd-3d2f-40ab-95e7-9a1ed5a2ffd2@vh10g2000pbc.googlegroups.com> <6Zcx$FIPQpRPFwYj@invalid.uk.co.demon.merlyn.invalid> <bnmdk7dbd04crei6qnaip7mosmesh8vkc8@4ax.com> |
In comp.lang.javascript message <bnmdk7dbd04crei6qnaip7mosmesh8vkc8@4ax.
com>, Thu, 23 Feb 2012 16:38:03, Gene Wirchenko <genew@ocis.net> posted:
>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.
You may think that. But I prefer to believe MDN; or, if something is
important to me, the results of tests. St Luke: Chapter 10, Verse 37,
tail; consider the implications of
<https://developer.mozilla.org/en/window.setInterval> "Dangerous usage"
>>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.
As above. A sensible operating system, operating on adequate hardware,
will not allow a single user process to exclude everything else. But
using timeouts is nicer.
There seems, though, to be a related fault in at least some browser
implementations : while (true) alert("") cannot be interrupted
except by killing at least the tab, maybe the window, maybe all windows
of that browser.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike 6.05 WinXP.
Web <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.
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