1. win32 sleep()

A few months ago I was looking for a simple system-speed-independent delay
that could do 'less' than Euphoria's sleep(integer) routine... and the
answer, of course, is... let win32 do it !

include win32lib.ew
atom stop  -- 'trick' stop
constant
winSleep=linkProc( kernel32, "Sleep",{C_INT})
atom ti
ti=time()
c_proc(winSleep,{125}) -- in milliseconds... well, almost blink
ti=time()-ti
printf(1,"slept for %3.3f seconds\n",{ti})

new topic     » topic index » view message » categorize

2. Re: win32 sleep()

Hi Wolfgang,
What do you mean by 'less'? As in more accurate? Well here's a routine I
    slapped together just cause you tempted me. :)
Compared against your's, mine is even more accurate, at least to the third
decimal.. and there is no need for any includes, let alone win32.

<CODE>

function sleeper(atom snooze)
atom sleep_timer,slept
slept = 0
   sleep_timer=time()
   while slept < snooze do
      slept = time() - snooze
   end while
   return slept
end function

printf(1,"%3.3f",sleeper(0.125))

<END CODE>

it MIGHT be a LITLE more accurate if you make it a procedure and get rid of the
slept variable. I only did it that way so I could easily print the elapsed time.

Chris

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu