sleep

alternate of sleep command in x code - iphone developement

I have implemented following in my application. for(i=0;!stopThroughButtons && i<totalMovements;i++){ [NSThread detachNewThreadSelector:@selector(moveNeedle) toTarget:self withObject:nil]; sleep(0.3); } Here sleep is a function with argument of unsigned int type. Sleep method uses seconds to sleep. I want to give the timing in ...

for loop execution doesn't permit touches on iPhone.

Ok. I know the title may be confusing. Logic That I have implemented is something like this. There is an detector in application ( like bike speedometer - moving arrow ) When user taps start scan button - first method executes. NowStartMovements decides random rotations & random number to stop There are 1 to 10 numbers on detector. Ev...

Cocoa Lock that does not use cpu power

Hi, I need a lock in cocoa that does not use one cpu when I try to lock it and it is locked somewhere else. Something that is implemented in the kernel scheduler. ...

Child process stops when Thread.sleep() is called (in Java under Windows)

I have a Java application that launches an external process (Internet Explorer) using ProcessBuilder. Strangely enough, this child process freezes when the parent Java thread calls Thread.sleep. It does not happen with all processes, for instance Firefox, but with IE it happens all the time. Any ideas ? P.S. I tried Robot.delay() with...

Problem with sound and alert when iPhone sleeps...

Hi I have an app almost written but there is one thing that I can't sort out. I have a timer and when this is running and the iPhone goes to sleep the "alarm" isn't called. In this case the alarm is an alert that pops up. The app just keeps running and the alert never pops up (or at least I don't think it does, could it be disappearing a...

Java: How does the method scheduledExecutorService.scheduleAtFixedRate() ensures real-time execution?

Hi there! Because I'm executing a time critical task every second, I compared several methods to find the best way to ensure that my task is really executed in fixed time steps. After calculating the standard derivation of the error for all methods it seems like using the method scheduledExecutorService.scheduleAtFixedRate() leads to th...

Shared Object Pool without Thread.Sleep?

I have developed an "object pool" and cannot seem to do it without using Thread.Sleep() which is "bad practice" I believe. This relates to my other question "Is there a standard way of implementing a proprietary connection pool in .net?". The idea behind the object pool is similar to the one behind the connection pool used for database ...

Is possible to use nanosleep in a infinite loop with select()?

Hi, I have a C program that do recv/send operations from/to socket using a for(;;) loop and a select() to monitor the file descriptor. I need also this program to send a packet every 80msec to a packet, how can I implement this? Maybe I can use a fork() and the child process simply write an ack in one of the file descriptor monitored b...

Can you flick the idleTimerDisabled boolean on and off from within your app?

For example I have a game with a menu screen and then I have the game itself. I want the timer disabled whilst playing the game but enabled when in the menu screen. I currently have the following code in my app delegate that disables the timer: application.idleTimerDisabled = YES; Any help would be appreciated. ...

Why does SetThreadExecutionState(ES_SYSTEM_REQUIRED) prevent display power-off?

I'm attempting to keep the system on while allowing the display to power off, to allow a download to finish while the system is unattended. To achieve this I call: SetThreadExecutionState(ES_SYSTEM_REQUIRED); whenever I get data from the download. However, this seems to prevent display power down as well (the display dims per its conf...

How can I stop PHP sleep() affecting my whole PHP code?

So, on my arcade, howlingdoggames.com. I have a points system that gives you a point every time you visit a page with a game on, now, to reduce abuse of this, I would like to make some sort of delay, so its only awarded after 45 seconds. Here's what i've tried. ... if ($_SESSION['lastgame'] != $gameid);{ sleep(45); $points...

How to make Sleep on background thread work with Invoke

I have a PictureBox control on a Form that is supposed to draw something every 100ms. The background thread performs some calculation in a loop and after every iteration, it fires an event. Edited (as a reply to a comment): World world = new World(); void CreateBackgroundThread() { Thread backgroundThread = new Thread(world.Backg...

iPhone Network Connection after kIOMessageSystemHasPoweredOn

I've built an app that runs in the background (jailbroken phone, Ver. 3.0/7A341) that checks my website every hour. When the device goes to sleep, I set a time to wake up if it stays asleep My app wakes up fine, then tries to make a network connection, but no luck. I've tried what iphone-3g-connection-enabling recommends (NSURLConnecti...

How to sleep for 5 seconds in Windows's Command Prompt? (or DOS)

Windows's Snipping tool can capture the screen, but sometimes I want to capture the screen after 5 seconds, such as taking an image being displayed by the webcam. (run the script and smile at the camera, for example). So in Ruby, I could do something like sleep 3 system('c:/windows/system32/SnippingTool.exe') but not all computer ha...

To make a choice between ManualResetEvent or Thread.Sleep()

I am not sure which strategy to adopt...I am focusing on my operation getting completed, but I'd also like to keep performance issues to a min too...there is a method called Execute() which has to wait (run synchronously) until an operation completes. This operation happens on another thread. There are 2 ways to implement the same thing....

how is sleep implemented at OS level?

I am just interested how sleep(time in ms) is implemented in C lib or basically at the os level.. I am guessing .. 1) may be the based on the processor speed you do a while loop of nop's ( not sure if the sleep time will be accurate).. 2) any special register in processor , where u write some value and the processor simply halts for sp...

wait for ajax response inside a loop

I need to wait for an ajax response inside a for loop. If I could I'd simply make a synchronous call instead of asynchronous, but I don't have that level of control: I'm using somebody else's API which in turn calls eBay's Javascript API. Below are my two functions, actually methods on the same closure/object, with categoryStack and ca...

Crash At Splash Screen, iPhone

Hi there, I have an app which when opened, displays a splash/loading screen. I had this set at 2.5 seconds before the app moved on. - (void)applicationDidFinishLaunching:(UIApplication *)application { sleep(2.5); [window addSubview:viewController.view]; [window makeKeyAndVisible]; } I now want the app to pause at the splash scre...

PHP sleep() inside loop not updating DB

Hello, I have a php file that is fired by a cronjob every minute. When the php file is fired it updates the database, sleeps, etc It is programmed like this: $start = microtime(true); set_time_limit(10); for($i=0;$i<5;$i++) { updateDB(); time_sleep_until($start + $i + 1); } If this piece of code is run i don't see any chan...

How do we check if the iphone is on standby mode?

How can we check if the iphone has gone into a standby mode and returns from that mode programmaticlly? I am using this to force it not to sleep during the game: application.idleTimerDisabled = YES; But if the user uses the sleep button it messes up with my game state in my code. Any help would be appreciated, thanks in advanced. ...