sleep

Task Delay vs Thread Sleep Resolution Accuracy

冷暖自知 提交于 2019-12-10 23:59:43
问题 i need to execute a function after a specific amount of time, therefore i use this code. _start = DateTime.Now; await Task.Delay(_app.Settings.AudioFileStartVarianz.BaseSpan).ContinueWith(x => { Console.WriteLine(DateTime.Now - _start); }); Lets say i want to wait for exactly 0.04 seconds. My problem now is that it's not working precise enough. I get following output after calling the function 5 times: 00:00:00.0414220 00:00:00.0536098 00:00:00.0507841 00:00:00.0467757 00:00:00.0425790 if i

Why doesnt set_time_limit work as expected? [duplicate]

笑着哭i 提交于 2019-12-10 23:38:00
问题 This question already has answers here : Closed 8 years ago . Take a quick look at the following snippet: <? set_time_limit(5); sleep(30); echo 'done'; ?> When I execute this on my boxes, the script takes the full 30 seconds, and displays 'done'. Why? Shouldnt it terminate in 5 seconds and not give the script the time to display 'done'? This is NOT in CLI mode. Nginx + PHP_FPM. Any ideas? I have opted to put the 'answer' in here as there is quite a few GOOD and VALID answers below. But... It

Interacting with IPhone while in sleep mode

ぐ巨炮叔叔 提交于 2019-12-10 21:13:39
问题 I want my app to keep running and interacting with the user, even if the user presses the sleep button. So far I have learned, that my app can stay alive with the following code: NSTimer *timer = [NSTimer timerWithTimeInterval:0.5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; This succeeds. The method - (void)timerFireMethod:(NSTimer*)theTimer will be called every 0.5s even if I am in sleep

What is the maximum value I can pass to std::thread::sleep_for() and sleep_until()?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 18:13:41
问题 This question on sleeping forever has an answer that mentions this: std::this_thread::sleep_until( std::chrono::time_point<std::chrono::system_clock>::max()); and this: std::this_thread::sleep_for( std::chrono::system_clock::durat‌​ion::max()); Running this code on Visual C++ 2017 RC actually doesn't sleep at all. I haven't checked out the sleep_until() case, so I'm not sure what's going on there. In the sleep_for() case, the given duration seems to be converted to an absolute time by adding

how to handle sleep mode enter in android?

爱⌒轻易说出口 提交于 2019-12-10 17:52:10
问题 I didn't find it anywhere, how can I handle entering sleeping mode in android? I want to do something when android device entered to the sleep mode? Is this possible or is there anyway to handle it? 回答1: Just make this by using BroadCastReceivers for system-calls (wakeup/sleep) Android - how to receive broadcast intents ACTION_SCREEN_ON/OFF? 回答2: how can I handle entering sleeping mode in android? Generally, you don't. There is nothing you need to do related to sleep mode. I want to do

High Frequency Ajax and MySQL Sleep Overload

风流意气都作罢 提交于 2019-12-10 17:18:58
问题 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 entire site, so I realize its a lot of requests as several hundred users are browsing the site at any given moment, many with several windows open. Syntax wise

understanding fork(), sleep() and processes flux

爱⌒轻易说出口 提交于 2019-12-10 16:09:29
问题 Been practicing with those system calls, but I stucked into this code: #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> main() { pid_t pid; switch(pid = fork()) { case -1: printf("fork failed"); break; case 0: //first child printf("\ni'm the first child, my pid is %d", getpid()); fflush(stdout); break; default: //parent sleep(5); /** sleep is generating problems **/ printf("\ni'm the parent process, my pid is %d", getpid()); printf("\ngenerating a new child"

command to wake up the windows system after sleep command

我与影子孤独终老i 提交于 2019-12-10 15:54:35
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 4 years ago . From C# program I want to call windows command prompt and make the system to sleep and after few seconds I should wake the system. I am successful in making the system sleep but I can't wake it up after few seconds. The command that I tried for making it sleep and wake up is "powrprof.dll,SetSuspendState 0,1,0 && timeout 10 && echo "Hello World" ". The link http://www.groovypost.com

How to change the delay of sleep/timer thread in android during runtime?

时光怂恿深爱的人放手 提交于 2019-12-10 13:16:18
问题 What I was trying to do was to decrease the timer delay every time the counter becomes a multiple of 5. But, as soon as the code entered the if block, it stopped incrementing the timer. I can't understand what is happening. This is the code thread=new Thread(){ public void run(){ try{ if(count%5==0) timre--; else{ //do nothing } //*******PROGRESS UPDATE********// for(t=0;t<=100;t++) { sleep((timre) / 100); progress.setProgress(t); t += 1; } //****PROGRESS UPDATE OVER****// } catch

How best to wake a sleeping Python thread?

为君一笑 提交于 2019-12-10 02:16:04
问题 There's an instrument on my LAN that sends a UDP data packet every 5-10 ms. In my application, I have a reader thread that allocates a socket with a large buffer when it starts, then enters an infinite loop to read the accumulated packets, parse them, write them to a spooler, then sleep for half a second ( time.sleep(0.500) ). I have several lazy consumers for the data, most of which do archiving or generate passive statistics. But one consumer (for display) needs up-to-the-moment data, and