So is it impossible to make a Sleep() function? - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: So is it impossible to make a Sleep() function? (/showthread.php?tid=61667) So is it impossible to make a Sleep() function? by segosa on 06-26-2006 at 10:38 PM
Someone on the IRC channel asked if JS had a Sleep() function to pause the script for x milliseconds, and apparently it doesn't. I tried to make my own function, but the problem is since it's not multithreaded it causes everything to freeze for the duration that you pause the script. code: Calling the Sleep() API with Interop.Call does the same. Is it possible? RE: So is it impossible to make a Sleep() function? by mathieumg on 06-26-2006 at 11:07 PM Like you said, as it is not multithreaded I don't think it is possible. That's why Patchou created timers. RE: So is it impossible to make a Sleep() function? by segosa on 06-26-2006 at 11:13 PM Hmm yeah of course, could probably make something using timers... RE: So is it impossible to make a Sleep() function? by CookieRevised on 06-26-2006 at 11:48 PM
Each time I needed a sleep() in programs I made, there were always better ways to do this. RE: So is it impossible to make a Sleep() function? by Riveck on 06-27-2006 at 12:14 AM
You could try to do something like this: RE: RE: So is it impossible to make a Sleep() function? by b0rna on 06-27-2006 at 12:42 AM
quote: This wont work, i thought of this and tried several methodes to achieve this perior to your post. once you enter the while loop you cannot break early, even the onEvent timer waits for the loop to end and thus it runs indefinatly. I really need a way to pause my script and have yet to find one. edit: after 3 hours of trying today i think it just might be impossible. RE: So is it impossible to make a Sleep() function? by TheBlasphemer on 06-27-2006 at 01:16 AM Erm... why on earth loop through GetTickCount when there's a win32 Sleep function ? RE: So is it impossible to make a Sleep() function? by b0rna on 06-27-2006 at 01:28 AM show us master for i am a nub RE: So is it impossible to make a Sleep() function? by -dt- on 06-27-2006 at 02:36 AM
why would you ever want to while loop to pause your code just pass a function and get the function which handles the timer to call it when it is up and you can use closures to pass variables code: more on javascript closures here http://jibbering.com/faq/faq_notes/closures.html RE: RE: So is it impossible to make a Sleep() function? by segosa on 06-27-2006 at 07:11 AM
quote: Read my post, I said I tried that too. RE: So is it impossible to make a Sleep() function? by ben_b on 07-14-2006 at 08:18 AM
So how could I make the following sleep for 5 seconds at the location indicated... code: RE: So is it impossible to make a Sleep() function? by CookieRevised on 07-14-2006 at 09:51 AM
I suggest you simply don't... quote: In the shown routine you could easly make that without the use of a dirty sleep() function. All you need in your case is to set a timer in the "IF (Msg==blah)" function and when that timer is triggered perform the status changes once more (two times). It would be much more elegant (and doesn't halt everything else). RE: So is it impossible to make a Sleep() function? by ben_b on 07-14-2006 at 09:55 AM
Exactly... I haven't been able to get the timers to work so I was looking for a little more help on how to make the timers work... here's my current code... code: RE: So is it impossible to make a Sleep() function? by sbegouin on 07-24-2006 at 10:27 PM
You can just use this DLL (see attachment) : code: RE: RE: So is it impossible to make a Sleep() function? by segosa on 07-25-2006 at 11:18 AM
quote: That just calls Sleep() which you can do with Interop.Call directly too. And it's not multithreaded, so it'll freeze WLM. RE: So is it impossible to make a Sleep() function? by sbegouin on 07-25-2006 at 06:10 PM This method doesn't freeze the processor (usage is at 0%) , but during this, you can't do anything with WLM. RE: RE: RE: So is it impossible to make a Sleep() function? by deAd on 07-25-2006 at 06:55 PM
quote:He never said it froze the processor. |