sleep

How accurate is python's time.sleep()?

I can give it floating point numbers, such as time.sleep(0.5) but how accurate is it? If i give it time.sleep(0.05) will it really sleep about 50 ms? ...

Symbian Power Status Notification

Hi, I have an application that uses memory card and I need to do some save/restore state operations when the power of the card reader is turned off and on back again. This usually happens after some time of activity and phone goes to a power save mode. In Windows Mobile I solved the same problem by receiving power notifications from the...

Touch files from Z->A with a delay

I need to do a touch of several files in a directory in reverse alphabetical order, with a 1 second delay. These files have spaces in their names. I've tried this: ls | sort -r | tr '\012' '\000' | xargs -0 touch and this: #!/bin/bash for i in $(ls -r); do touch "$i" sleep 1 done but the first makes it too quick and doesn...

Set sleep time in C#

I want to send data every two minutes. Right now, I have the following code: using (var client = new WebClient()) { byte[] responseArray = client.UploadValues(Server, myNameValueCollection); Answer = Encoding.ASCII.GetString(responseArray); } I don't know how can I do this. I tried to add something like this to my code: pr...

Detect OS Sleep and Wake Up events in Java

Is there a way for a Java program to detect when the operating system is about to go to sleep, or failing that, at least detecting a wake up? The actual problem is that in a particular application a number of MySQL database operations are run in the background. In testing on a Windows machine these database transactions are interrupted ...

Disable/Cancel Sleep Command on MacOSX

It seems to be impossible to completely disable the Sleep option in MacOSX so that a user cannot manually put the system to sleep. Is there a way in Leopard (or even Snow Leopard) for AppleScript to catch the Sleep event and cancel it? ...

PHP usleep/sleep inside output buffer

Hello, I have a PHP application containing these files: landing.php, redirect.php, ajax.php on a page call to landing.php, I execute a javascript code to capture certain data, and issue an AJAX POST to ajax.php which inserts them into DB. Finally php header() redirects to redirect.php Currently the above feature is using output buf...

Is there an equivalent Javascript or Jquery sleep function ?

Hi. I want something like this in javascript. for (i = 0; i < 10; i++) { alert(i); // now sleep 1 sec sleep(1000); } is there a built in Javascript or Jquery for this? Thank you! ...

How accurate is Thread.Sleep(TimeSpan)?

I've come across a unit test that is failing intermittently because the time elapsed isn't what I expect it to be. An example of what this test looks like is: Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); TimeSpan oneSecond = new TimeSpan(0, 0, 1); for(int i=0; i<3; i++) { Thread.Sleep(oneSecond); } stopwatch.Stop();...

Python question regarding a server listener

I wrote a plug-in for the jetbrains tool teamcity. It is pretty much just a server listener that listens for a build being triggered and outputs some text files with information about different builds like what triggered it, how many changes there where ect ect. After I finished that I wrote a python script that could input info into tea...

Tell Ruby Program to Wait some amount of time

How do you tell a Ruby program to wait an arbitrary amount of time before moving on to the next line of code? thanks ...

Programs run in 2 seconds on my machine but 15 seconds on others.

I have two programs written in C++ that use Winsock. They both accept TCP connections and one sends data the other receives data. They are compiled in Visual Studio 2008. I also have a program written in C# that connects to both C++ programs and forwards the packets it receives from one and sends them to the other. In the process it coun...

Sleep between calls of Mail() in PHP

How would i send an email, to say 3000 recipients - with a Max 500 emails / hours on my dedicated IP? So far my thought is to send each email every 9 seconds, this would come to about 450 emails an hour... but how could i do this? My plan for the sending of the emails would be the following... $emails = ARRAY OF EMAILS, MYSQL RESULT fo...

Ruby Loop Failing in Thread

I have a thread in Ruby. It runs a loop. When that loop reaches a sleep(n) it halts and never wakes up. If I run the loop with out sleep(n) it runs as a infinite loop. Whats going on in the code to stop the thread from running as expected? How do i fix it? class NewObject def initialize @a_local_var = 'somaText' end ...

AccessViolationException while executing Threading.Thread.Sleep

We have developed an application that has intensive thread use (+-50 threads) in Vb.Net. From time to time we get an AccessViolationException at a random thread while it is doing a Thread.Sleep(). As far as we know we're no executing unsafe code as all our code is managed. We're using DevExpress controls but we don't know if they have u...

Sleep Windows from Java

Is there command to use on windows from java to make the computer sleep? ...

SwitchToThread vs Sleep(1)

I'm wondering what's the actual difference between calling Thread.Sleep(1) and calling SwitchToThread (if we ignore that it's currently not exposed by the BCL). Joe Duffy mentions in his post that: "The kernel32!SwitchToThread API doesn't exhibit the problems that Sleep(0) and Sleep(1) do." (regarding the scheduler's behavior) Why...

Sleep() becomes less accurate after replacing a PC? (C++)

I have a program that was built in C++ (MFC, Visual Studio 6.0) several years ago and has been running on a certain Windows machine for quite some time (more than 5 years). The PC was replaced a month ago (the old one died), and since then the program's timing behavior changed. I need help understanding why. The main functionality of th...

Pause execution of a method without locking GUI. C#

I'm working on a card game in C# for a project on my Intro to OOP paper and have got the game working now but am adding "flair" to the GUI. Currently cards are dealt and appear on the UI instantaneously. I want to have to program pause for a moment after dealing a card before it deals the next. When a game is started the following code...

Timer & TimerTask versus Thread + sleep in Java

I found similar questions asked here but there weren't answers to my satisfaction. So rephrasing the question again- I have a task that needs to be done on a periodic basis (say 1 minute intervals). What is advantage of using Timertask & Timer to do this as opposed to creating a new thread that has a infinite loop with sleep? Code snip...