Saturday, December 29, 2007

JavaScript: Sleep function

// ***
// Pauses all functionality sleeps the thread for specified time
// ***
function sleep(milliseconds)
{
var now = new Date();
var exitTime = now.getTime() + milliseconds;
while (true)
{
now = new Date();
if (now.getTime() > exitTime)
return;
}
}

3 comments:

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.