sleep

Best Way to wake a thread up to quit? C#

I spawn a thread (only one) to do some work and it pretty much takes care of itself not accessing any data outside of the tread except calling callback() to see if the user wants to quit (also sends a status report back to the main thread to display in the GUI). When the close closes the exe i would like to wake up the thread and have i...

Simple, non-blocking way to sleep?

Hello I googled for this and read some threads here, but I haven't found a simple way to have a VB.Net application sleep for a little while and still keep the application responsive: Imports System.Net Imports System.IO Imports System.Text Imports System.Text.RegularExpressions Imports System.Threading.Thread [...] ''#How to keep scr...

C# - How to Suspend to RAM and wakeup

Hi, I want to make a utility that will allow the system to use the Suspend to RAM feature and also have the ability to wakeup at a certain time. Is this possible and how can I do this? Code snippets would be great to look at. Thanks ...

How do you make a program sleep in C++ on Win 32?

How does one "pause" a program in C++ on Win 32, and what libraries must be included? ...

usleep() function does not allow a loop to continue

#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int i=0; while(i<10) { printf("%d", i); usleep(10000); // or sleep(1) i++; } return 0; } I want the program to last 10 secs, i.e. print 1 - wait 1 sec - print 2 - wait 1 se...

Simulating Java's Thread.sleep() in WM

Is there an easy way to make some "sleeping program" functionality by just calling function, such as it has been made in Java with Thread.sleep()? Sleep method causes, in brief, app to wait indicated time (no. of milisec.) and after that time returns to next line of code (so it "blocks" - it isn't not proper word, though - the current t...

High Frequency Ajax and MySQL Sleep Overload

I am currently working on a light php framework to use with some high request ajax for my site, and have run into an interesting problem that has me completely stumped. The ajax is for a series of notifications, so the javascript sends off an ajax request for new information every 30 seconds. This ajax is active on every page of the enti...

Core Location while iPhone locked

Hi, I was reading your comment below: "I don't know what you mean by "power save" mode, but if you're thinking of when the screen is locked/off, that does not stop Core Location from running if your app is still running. On the contrary it's easy to run down your phone's battery much more quickly than you'd expect if you lock the phone...

Python's time.sleep - never waking up

I think this is going to be one of those simple-when-you-see-it problems, but it has got me baffled. [STOP PRESS: I was right. Solution was found. See the answers.] I am using Python's unittest framework to test a multi-threaded app. Nice and straight forward - I have 5 or so worker threads monitoring a common queue, and a single produ...

Can a ThreadAbortException be raised during Thread.Sleep ?

Can Thread.Abort interrupt a thread that is sleeping (using, say, Thread.Sleep(TimeSpan.FromDays(40)) ? Or will it wait until the sleep time span has expired ? (Remarks: FromDays(40) is of course a joke. And I know Thread.Abort is not a recommended way to stop a thread, I'm working with legacy code that I don't want to refactor for now....

Sleep function uses server resources?

I've got two reasons to use a sleep function: first, to automatically send a confirmation email to a client 20 minutes after they contact us. I don't want to use cron jobs because I want it to be exactly 20 minutes (and I'm sick of my web server sending me emails telling me they initiated a cron job.....a new email every 20 minutes!) Se...

Iphone app is delayed for 10 -15 minutes when iphone is in sleep mode.

Hello Experts! I have created an app that uses NSTimer, which gets triggered each second. My problem is that if the Iphone is in sleep mode i get a delay for 10 to 15 minutes before the event is triggered. I have stackoverflowed and googled this and the reason for this seems to be that the phone stops listening for certain events when...

Thread Sleep and Windows Services

I'm working on a Windows Service that's having some issues with Thread.Sleep() so I figured I would try to use a timer instead as this question recommends: http://stackoverflow.com/questions/998142/using-thread-sleep-in-a-windows-service Thing is it's not entirely clear to me how one might implement this. I believe this is the way but ...

Network access when the Android phone is asleep

I'm using a combination of alarm (set with AlarmManager) and background service to periodically synchronize data in my application. The only problem I have is that when sleep policy terminates Wi-Fi connection the synchronization no longer works. Is there a way to "wake up" the Wi-Fi connection that has been put to sleep? GMail somehow...

iPhone still sleeping with the proper API calls

On Init, I call: [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; My 3GS will never goto sleep while unplugged, but my 3G will. Any ideas? Rebooting will sometimes fix the issue, but it just crops up again.. Both phones have the latest OS. I've even tried putting that on a 1sec NSTimer, still nothing. The screen will ...

usleep() php5 uses 40% of idle CPU

Hi guys I have a weird question, I have a cli php script runs on Centos 5.x which uses usleep (somtimes 1sec, sometimes 2sec, somtimes 100ms it depends) if there is some wait required, but what I have noticed its that once on usleep() it seems to use about 40% of idle CPU: Cpu(s): 5.3%us, 21.3%sy, 0.0%ni, 57.2%id, 0.0%wa, 0.0%hi, ...

Enable iPhone accelerometer while screen is locked..

So apparently it is possible to keep the processor going processing stuff while the screen is locked, as indicated here: http://stackoverflow.com/questions/1551712/running-iphone-apps-while-in-sleep-mode However, after testing with the example code, UIAccelerometer will just stop giving value as soon as the device is locked pronto. Is ...

C# Sleep for 500 milliseconds

Could you please tell me how do I go about pausing my program for 500 milliseconds and then continue? I read Thread.Sleep(500) is not good as it holds up the GUI thread. Using a timer it fires a callback ... I just want to wait 500ms and then continue to the next statement. Please advise. EDIT: I need to display a status bar message...

Does QThread::sleep() require the event loop to be running?

I have a simple client-server program written in Qt, where processes communicate using MPI. The basic design I'm trying to implement is the following: The first process (the "server") launches a GUI (derived from QMainWindow), which listens for messages from the clients (using repeat fire QTimers and asynchronous MPI receive calls), up...

Is it possible to write an Android broadcast receiver that detects when the phone wakes up?

I want to figure out how to detect when the phone wakes up from being in the black screen mode and write a handler for that event. Is that possible? It seems like this would be something a Broadcast Receiver should handle? Or is there a better or more proper way? Thanks ...