Sleep problem

Previous topic - Next topic

msx

It  works perfectly without using SHOWSCREEN.

Thank you. ;)

Kitty Hello

please put a SLEEP before that loop to enable some CPU relief where it works:
Code (glbasic) Select

FUNCTION Pause%: delay%
  LOCAL time_start% = GETTIMERALL()
  SLEEP delay%
  WHILE ABS(GETTIMERALL() - time_start) < delay
    // SHOWSCREEN
  WEND
ENDFUNCTION

Slydog

So, would this make sense then:
Code (glbasic) Select
FUNCTION Pause%: delay%
  LOCAL time_start% = GETTIMERALL()
  WHILE ABS(GETTIMERALL() - time_start) < delay
    SLEEP 1     // Sleep 1ms
  WEND
ENDFUNCTION

Whether SLEEP is working properly or not for the platform (iPod or PC), it will act the same, and giving your CPU some relief either way.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Moebius

It does make sense, but Gernot's example works just as well, if not better... (I doubt executing the code for a loop every millisecond would impede performance though)
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

erico

I believe the best way to use sleep is to make it at least 8h a day... =D
...sorry to bother a serious thread...just could not help as I haven't got sleep the last 3 days for ear infection :sick:

DaCarSoft

Hello!

This is my first post here.

Before of all, I would like to send my congratulations because of the work that makes possible GLBasic and the good answers of this community.

Now, I'm creating my own functions to work with GLBasic, and I also found that Sleep does not work in my iPad (iOS and SDK 4.2) while testing, but for me it does not work if it is inside of a loop.

I can workaround it in many ways, but reading this thread (as a newbie to GLBasic), I'm asking me now if the next code does make sense:

Code (glbasic) Select
FUNCTION Pause%: delay%
  LOCAL time_start% = GETTIMERALL()
  SLEEP delay%
  WHILE ABS(GETTIMERALL() - time_start) < delay
    HIBERNATE
  WEND
ENDFUNCTION


Thanks in advance!


"Si quieres resultados distintos... no hagas siempre lo mismo" - Albert Einstein.