sleep

How to programmatically prevent linux computer from sleeping or turning on screensaver?

时光怂恿深爱的人放手 提交于 2020-07-17 09:37:48
问题 While developing a small cross-platform game on C++, I got stuck with following issue: when players are playing with a USB gamepad without touching a keyboard or mouse, the computer sleeps automatically while they're playing. In Windows, it can be done easily using SetThreadExecutionState function. In OS X, I think it can be done with UpdateSystemActivity but not tested yet. But the problem is, in Linux there's nothing like a common API between DE's. I've found that in Gnome you can stop the

querying DB in a loop continuously in java

白昼怎懂夜的黑 提交于 2020-07-09 08:39:48
问题 Is it advisable to query a database continuously in a loop, to get any new data which is added to specific table? I have below a piece of code: while(true) try{ // get connection // execute only "SELECT" query } catch(Exception e){} finally{// close connection } //Sleep 5 sec's } 回答1: It is a simple approach that works in many cases. Make sure that the select statement you use doesn't put as little load as possible on the database. The better (but more difficult to setup) variant would be

Sleep / wait timer in PowerPoint VBA that's not CPU intensive

和自甴很熟 提交于 2020-07-07 09:40:17
问题 I'm currently having a PowerPoint presentation that's being used on a computer as some sort of kiosk or information screen. It reads it's text from a text file on the disk. The text in this text file is displayed in a textbox in PowerPoint and this is being refresh every 5 seconds. This way we can edit the text in the PowerPoint without editing the PowerPoint presentation itself so it will continue to run. Work great so far, only PowerPoint VBA does not contain the Application.Wait function.

Sleep / wait timer in PowerPoint VBA that's not CPU intensive

拜拜、爱过 提交于 2020-07-07 09:39:30
问题 I'm currently having a PowerPoint presentation that's being used on a computer as some sort of kiosk or information screen. It reads it's text from a text file on the disk. The text in this text file is displayed in a textbox in PowerPoint and this is being refresh every 5 seconds. This way we can edit the text in the PowerPoint without editing the PowerPoint presentation itself so it will continue to run. Work great so far, only PowerPoint VBA does not contain the Application.Wait function.

Sleep / wait timer in PowerPoint VBA that's not CPU intensive

守給你的承諾、 提交于 2020-07-07 09:38:00
问题 I'm currently having a PowerPoint presentation that's being used on a computer as some sort of kiosk or information screen. It reads it's text from a text file on the disk. The text in this text file is displayed in a textbox in PowerPoint and this is being refresh every 5 seconds. This way we can edit the text in the PowerPoint without editing the PowerPoint presentation itself so it will continue to run. Work great so far, only PowerPoint VBA does not contain the Application.Wait function.

Reliably kill sleep process after USR1 signal

淺唱寂寞╮ 提交于 2020-06-25 03:36:33
问题 I am writing a shell script which performs a task periodically and on receiving a USR1 signal from another process. The structure of the script is similar to this answer: #!/bin/bash trap 'echo "doing some work"' SIGUSR1 while : do sleep 10 && echo "doing some work" & wait $! done However, this script has the problem that the sleep process continues in the background and only dies on its timeout. (note that when USR1 is received during wait $!, the sleep process lingers for its regular

Suspend / Hibernate pc with python

北战南征 提交于 2020-06-08 19:31:30
问题 I'd like to write a short python script that puts my computer to sleep. I'Ve already searched the API but the only result on suspend has to do with delayed execution. What function does the trick ? 回答1: You can run shell command from python script. See subprocess module and then search for appropriate command for your operating system. 回答2: I don't know how to sleep. But I know how to Hibernate (on Windows). Perhaps that is enough? shutdown.exe is your friend! Run it from the command prompt.

Suspend / Hibernate pc with python

倾然丶 夕夏残阳落幕 提交于 2020-06-08 19:31:28
问题 I'd like to write a short python script that puts my computer to sleep. I'Ve already searched the API but the only result on suspend has to do with delayed execution. What function does the trick ? 回答1: You can run shell command from python script. See subprocess module and then search for appropriate command for your operating system. 回答2: I don't know how to sleep. But I know how to Hibernate (on Windows). Perhaps that is enough? shutdown.exe is your friend! Run it from the command prompt.

wait x seconds or until a condition becomes true

眉间皱痕 提交于 2020-05-25 12:12:45
问题 How to wait x seconds or until a condition becomes true? The condition should be tested periodically while waiting. Currently I'm using this code, but there should be a short function. for (int i = 10; i > 0 && !condition(); i--) { Thread.sleep(1000); } 回答1: Assuming you want what you asked for, as opposed to suggestions for redesigning your code, you should look at Awaitility. For example, if you want to see if a file will be created within the next 10 seconds, you do something like: await()

wait x seconds or until a condition becomes true

本小妞迷上赌 提交于 2020-05-25 12:09:44
问题 How to wait x seconds or until a condition becomes true? The condition should be tested periodically while waiting. Currently I'm using this code, but there should be a short function. for (int i = 10; i > 0 && !condition(); i--) { Thread.sleep(1000); } 回答1: Assuming you want what you asked for, as opposed to suggestions for redesigning your code, you should look at Awaitility. For example, if you want to see if a file will be created within the next 10 seconds, you do something like: await()