Все вопросы: [sleep]

90 вопросов

похожие теги: sleep-modethread-sleep
0
голосов
2ответов
3425 просмотров

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 d...

0
голосов
2ответов
1406 просмотров

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 wou...

0
голосов
1ответов
685 просмотров

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

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 o...

2
голосов
2ответов
982 просмотров

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 beh...

1
голосов
2ответов
2774 просмотров

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

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.sc...

2
голосов
1ответов
1191 просмотров

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...

0
голосов
4ответов
573 просмотров

Cocoa Lock that does not use cpu power

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.

0
голосов
2ответов
171 просмотров

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 ...

9
голосов
4ответов
33591 просмотров

alternative for sleep function

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 the sleep is a function with argument of unsigned int t...

102
голосов
7ответов
97651 просмотров

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 t...

5
голосов
4ответов
19519 просмотров

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. ...

4
голосов
6ответов
2256 просмотров

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 unders...

17
голосов
2ответов
7261 просмотров

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." ...

2
голосов
6ответов
6854 просмотров

Sleep Windows from Java

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

0
голосов
1ответов
367 просмотров

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...

0
голосов
1ответов
810 просмотров

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 ...

1
голосов
5ответов
5129 просмотров

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... ...

2
голосов
2ответов
254 просмотров

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...

34
голосов
4ответов
24915 просмотров

Delay or Wait-For Statement

I have a 500,000 line SQL script: update users set region_id = 9814746 where id = 101 and region_id is null; update users set region_id = 9814731 where id = 102 and region_id is null; update users set region_id = 3470676 where id = 103 and region_id is null; I want to INSERT a delay of 10 seco...

418
голосов
6ответов
327720 просмотров

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?

0
голосов
2ответов
402 просмотров

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 etc etc. After I finished that I wrote a py...

17
голосов
6ответов
14946 просмотров

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++) { ...

5
голосов
7ответов
37444 просмотров

Is there an equivalent Javascript or Jquery sleep function?

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!

0
голосов
1ответов
1509 просмотров

PHP usleep/sleep inside output buffer

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 ...

4
голосов
3ответов
2140 просмотров

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?

11
голосов
3ответов
5496 просмотров

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 th...

1
голосов
5ответов
8505 просмотров

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 t...

1
голосов
4ответов
1529 просмотров

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 '#!/bin/bash for i in $(ls -r); do touch "$i" sleep 1 done 12' '1232100' | xargs -0 touch and this: 1...

0
голосов
1ответов
402 просмотров

Symbian Power Status Notification

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 r...

136
голосов
6ответов
306941 просмотров

Is there an alternative sleep function in C to milliseconds?

I have some source code that was compiled on Windows. I am converting it to run on Red Hat Linux. The source code has included the <windows.h> header file and the programmer has used the Sleep() function to wait for a period of milliseconds. This won't work on the Linux. However, I can u...