>From what I understand, is that that elapsed time is computed by capturing the intial time and polling the system clock for elapsed time. So when the system clock changes, the elapsed time increases. IE implements this by having its own timer and thus changing system time does not affect the elapsed time. Does this sound like a reasonable explanation?
On Mar 23, 1:03 pm, Thomas Broyer <[email protected]> wrote: > On 23 mar, 17:14,SalmanHemani <[email protected]> wrote: > > > I am seeing a strange behaviour so I'd appreciate if someone can > > explain the workings of the Timer class to me. > > The Timer class uses setTimeout or setInterval behind the scene > (depending whether you call schedule() or scheduleRepeating() method), > which are "native" browser functions. > They're unfortunately not part of any standard, but a draft is > available (so expect browsers to align on the same behavior in their > next version, if that's not already the case) in > HTML5:http://www.w3.org/TR/html5/no.html#timershttp://www.whatwg.org/specs/web-apps/current-work/multipage/no.html#t... > > > > > > > I have a piece of code that executes in the run() method when a > > disconnection from the server is detected. More specifically, the user > > is prompted a message for disconnection if the server stops sending a > > ping. If I get a ping I will reset the timer. If I do not get a ping > > within 20 seconds I will show the disconnection message. > > > So here is the problem. If I change my system time, the disconnection > > message is displayed to the user right away. More specifically, I > > change the time 1 minute into the future. I also tried 20 seconds into > > the future and it also disconnected. But if change the time into the > > past it doesn’t matter. I would also say that changing the time into > > the future by 5 seconds or anything below 20, does not affect the > > timer (although more testing is required). > > > Is the time change affecting how the timer operates? Is it determining > > the elapsed time based on the system clock? > > Unfortunately, HTML5 defines setTimeout/setInterval to "asynchronously > wait <var>timeout</var> milliseconds" which can be interpreted one way > or the other (and seem to be implemented as computing the timestamp > when the timer should run and having a thread "poll" timers that have > an elapsed timestamp). > > I suggest you ask the WHATWG or W3C HTML WG for clarification (see the > "Status of this document" section ofhttp://www.w3.org/TR/html5/)- Hide quoted > text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
