Sleep problem

Previous topic - Next topic


Is there any known Sleep command problem when compiling for iPhone? I don't remember having issues with it in the past, but I have not tried using it since I have the latest build of GLBasic. Now it does not seem to work at all on the iPhone/iPod. When I compile and run within the IDE it works just like it should, but when I send it to the iPod there is no pause at all rather I make it Sleep 200 or Sleep 2000.

Any thoughts on this? Been trying different situations and sleep seems to always work in the IDE, but never on the iPhone/iPod anymore.

Thanks Much,


I have the same problem, but i found it seems to only occur on older ipods/iphones. On my iPhone 4 the sleep command works without any problems, on iPod Touches 8gb/32gb it doesn't work.


The ones I am having the problem with are a 3rd gen 8 gig and a 3rd gen 32 gig. Any other way to easily make the program pause without requiring user input to continue?


For the time being, use GETTIMERALL() and calculate the amount of time you want to wait for, with something like :

Code (glbasic) Select
WHILE ABS(GETTIMERALL()-finishTime%)<1000


Thanks alot for that piece of code. I will try it out. Looks like that should do the trick.



I rtoo have a sleeep problem..

I don't get enough of it.. lol


Ian Price

I'll sleep when I'm dead. Until then I'll code (pausing for the odd cup of cold tea and some pizza) :P
I came. I saw. I played.


True - I wonder even if the SLEEP command isn't sleeping per say on the offending machines, it does still relinquish control back to the operating system.


More to the mystery...The same app has Sleep commands scattered throughout and they all work but the one section. So I started looking at what the difference is. Here is what I found. All of my Sleep commands that are within a loop such as an IF or WHILE loop work fine. The ones that do not are the ones that are out on their own. Here is basically what I am doing in the section that does not work.

I draw and move a sprite to a certain point. I want the sprite to change to another sprite, sleep, then change back and continue to move. The effect is to produce a face winking. When I run in the IDE it is perfect. When I run it on the iPod there is no pause at all no matter what highly ridiculous number I can put in for Sleep. These sleep commands are not within any kind of loop. That is the only difference I can see between the ones that work and the ones that do not.

Hope this helps,


Good thing to know.
Current Project, Orbital Contract Defense

BlackShadow now open source/resource(requires duke3d)

Kitty Hello

What OS version is that iPod ignoring sleep?


The version is 4.1 . Real weird. I've never had the problem before. Even in the same program. The Sleep commands that were not working were not in a loop. I know most things are in a loop in one way or another, but these commands were used for an intro screen and only execute once. Ran fine in the GLBasic IDE when compilied and ran. Once on the iPod it did not pause at all. Went so fast you never saw the sprite change.

Hope this helps. I used a work around for the time being.



Is there any solution for this problem?


If not, you could create your own temporary function, using the above code.
And to get around the problem of relinquishing control back to the OS, a simple 'SHOWSCREEN' should help I think.

Code (glbasic) Select
FUNCTION Pause%: delay%
  LOCAL time_start% = GETTIMERALL()
  WHILE ABS(GETTIMERALL() - time_start) < delay
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]