[Project_owners] Sleep or wait function for JavaScript

joe ertaba belaviyo at gmail.com
Mon Oct 27 12:06:56 PDT 2008


Hi

I need to add sleep function in some procedure, I found some sleep function

function sleep(mTime)
{
  var sleeping = true;
  var now = new Date();
  var alarm;
  var startingMSeconds = now.getTime();
  while(sleeping){
     alarm = new Date();
     alarmMSeconds = alarm.getTime();
     if(alarmMSeconds - startingMSeconds > mTime)
        sleeping = false;
  }
}

but it causes program to hang, any better sleep function ?
P.S: I cant use setTimeout function either
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20081027/c0e4da17/attachment.html>


More information about the Project_owners mailing list