Search found 2 matches

Actual Results

Post Posted: October 10th, 2008, 12:25 pm

joebert, I admit that sleeping in JavaScript is a kludgy thing to do, especially if we're talking about a Web application. Any time I consider sleeping, I usually come up with a more elegant solution. I came across this discussion because I finally found a case where I really did want to sleep. I wa...

Post Posted: September 30th, 2008, 4:10 pm

Excellent concept, Carnix. I think we can implement it with less code:
Code: [ Download ] [ Select ]
/**
* Delay for a number of milliseconds
*/
function sleep(delay)
{
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}
  1. /**
  2. * Delay for a number of milliseconds
  3. */
  4. function sleep(delay)
  5. {
  6.     var start = new Date().getTime();
  7.     while (new Date().getTime() < start + delay);
  8. }
  • Sort by
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.