sleep

time.sleep(x) not working as it should? [duplicate]

ぐ巨炮叔叔 提交于 2019-11-30 20:14:51
This question already has an answer here: How to print one character at a time on one line? 3 answers Okay, so I'm making a small programme for fun and I'd like to create a refresh button that allows the user to control how regularly the data is collected and shown. I decided to use the time.sleep(x) x being what the raw_input was. But it doesn't seem to be working as it should. It pauses the full script then does everything. eg: import time print "This now" time.sleep(x) print "and this after x amount of seconds" So should print the first part then the second after x amount of seconds. But

C# Label Text Not Updating

≯℡__Kan透↙ 提交于 2019-11-30 18:45:30
I have the following code: private void button1_Click(object sender, EventArgs e) { var answer = MessageBox.Show( "Do you wish to submit checked items to the ACH bank? \r\n\r\nOnly the items that are checked and have the status 'Entered' will be submitted.", "Submit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (answer != DialogResult.Yes) return; button1.Enabled = false; progressBar1.Maximum = dataGridView1.Rows.Count; progressBar1.Minimum = 0; progressBar1.Value = 0; progressBar1.Step = 1; foreach (DataGridViewRow row in dataGridView1.Rows) {

Is there a way to wake a sleeping thread?

試著忘記壹切 提交于 2019-11-30 17:36:34
Is there a way to wake a sleeping thread in C#? So, have it sleep for either a long time and wake it when you want work processed? An AutoResetEvent object (or another WaitHandle implementation) can be used to sleep until a signal from another thread is received: // launch a calculation thread var waitHandle = new AutoResetEvent(false); int result; var calculationThread = new Thread( delegate { // this code will run on the calculation thread result = FactorSomeLargeNumber(); waitHandle.Set(); }); calculationThread.Start(); // now that the other thread is launched, we can do something else.

How to sleep in the Linux kernel?

江枫思渺然 提交于 2019-11-30 17:27:41
Can I use the msleep() function to sleep for a specified amount of time in kernel space? If so, which header files do I need to include? #include <linux/time.h> doesn't seem to be the right one. Is there perhaps a better function for this purpose? I needed to include <linux/delay.h> to use msleep in kernel space. Linux kernel documentation The Linux kernel documentation under Documentation/timers/timers-howto.txt has a good rundown of the main methods: Inserting Delays ---------------- The first, and most important, question you need to ask is "Is my code in an atomic context?" This should be

How to make a Windows 10 computer go to sleep with a python script?

你离开我真会死。 提交于 2019-11-30 16:42:42
How can I make a computer sleep with a python script? It has to be sleep , not hibernate or anything else. I have tried to use cmd but there is no command to sleep or I didn't find one. You can use import os os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0") If this command doesn't work for you (it actually puts your comp. in hibernation mode) you will need to turn hibernation off: Powercfg -H OFF To turn hibernation mode back on: Powercfg -H ON Alternatively, you can also use: Rundll32.exe Powrprof.dll,SetSuspendState Sleep If you don't want to turn hibernation off just to run a

How to Delay without freezing - Inno Setup

做~自己de王妃 提交于 2019-11-30 16:39:07
Hello I like to know how can I delay a work (or a command) for a specified time in Inno Setup Pascal Script. The built in Sleep(const Milliseconds: LongInt) freezes all work while sleeping. And the following function I implemented also makes the WizardForm unresponsive but not freezing like built in Sleep() Function. procedure SleepEx(const MilliSeconds: LongInt); begin ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(MilliSeconds div 1000), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); end; I also read this , but can't think how to use it in my Function. I like to know how can I use

How to Delay without freezing - Inno Setup

荒凉一梦 提交于 2019-11-30 16:18:33
问题 Hello I like to know how can I delay a work (or a command) for a specified time in Inno Setup Pascal Script. The built in Sleep(const Milliseconds: LongInt) freezes all work while sleeping. And the following function I implemented also makes the WizardForm unresponsive but not freezing like built in Sleep() Function. procedure SleepEx(const MilliSeconds: LongInt); begin ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(MilliSeconds div 1000), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);

Why using System.Threading.Thread.Sleep() is a bad practice?

…衆ロ難τιáo~ 提交于 2019-11-30 15:51:25
问题 I'm writing an application working with a big and ugly 3rd party system via a complicated API. Sometimes some errors happen in the system, but if we wait for my program to face this errors it can be too late. So, I use a separate thread to check the system state as following: while (true) { ask_state(); check_state(); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); } It doesn't really matter if I check the system state once in 100 ms or once a minute. But I have heard that using

Sleeping in a Thread (C / POSIX Threads)

≯℡__Kan透↙ 提交于 2019-11-30 14:49:10
问题 I am developing a multithreaded application that makes use of POSIX Threads. I am using threads for doing a periodical job and for that purpose I am using usleep(3) to suspend thread execution. My question is how can I cancel usleep() timer from the main thread, I tried pthread_kill(thread, SIGALRM) but it has a global effect which results in termination of the main application (by default). Here is my pseudo code: void threaded_task(void *ptr) { initialize(); while(running) { do_the_work();

What event is fired when Mac is back from sleep?

廉价感情. 提交于 2019-11-30 13:58:53
问题 I am developing an app in Xcode on Mac and would like to know the event which is fired when the mac gets back from sleep. AwakeFromNib doesn't seem to work. Thanks ! 回答1: Just found it: - (void) receiveWakeNote: (NSNotification*) note { NSLog(@"receiveSleepNote: %@", [note name]); } - (void) fileNotifications { //These notifications are filed on NSWorkspace's notification center, not the default // notification center. You will not receive sleep/wake notifications if you file //with the