sleep

Pause/resume a thread in C#

◇◆丶佛笑我妖孽 提交于 2021-02-05 08:40:34
问题 I try to pause all my threads when I reach a certain value but I can't do it. I would like that when I reach this value all threads are paused for 10 seconds and after these 10 seconds all threads start again. I tried that with : Threads.Sleep(); | Threads.Interrupt(); and Threads.Abort(); but nothing work. I tried what you can see in the code below. static void Main(string[] args) { for (int i = 0; i < 10; i++) { Threads.Add(new Thread(new ThreadStart(example))); Threads[i].Start(); } for

Using a timer to delay a line by line readline method C#

不羁的心 提交于 2021-01-29 17:43:04
问题 I am using C# Windows Forms using Visual Studio 2010. Don't let the Console part confuse you it's a user defined thing not the actual console. So I have a method that prints a file line by line. I have to make it appear to print slowly so I am currently using Thread.Sleep to slow the line by line printing. I cannot use this because it freezes up some other components in the program. I was hoping to see if this could be done with a timer instead. Though all the examples I see being used with a

Using sleep in JPanel

情到浓时终转凉″ 提交于 2021-01-29 03:30:22
问题 I wrote a simple java program to place some rectangles on the screen (after some delay between each other) package guitest2; import java.awt.Graphics; import javax.swing.JPanel; public class DrawPanel extends JPanel { public void paintComponent( Graphics g) { super.paintComponent(g); for (int i = 0; i < 10; i++ ) { g.drawRect(10+5*i, 10+5*i, 20, 20); try{ Thread.sleep( 2000 ); } catch (InterruptedException ex) { } } } } I used that class in package guitest2; import javax.swing.JFrame; public

Why Isn't My Windows 10 PC Waking Up after a SetWaitableTimer() Call?

人走茶凉 提交于 2021-01-27 12:51:28
问题 I have two Windows 10 PCs, both running the Fall Creators Update, with all recent patches installed. One wakes up from sleep after a timer is set via CreateWaitableTimer/SetWaitableTimer, the other doesn't...which is a problem, because the non-waking one is my DVR and needs to be able to wake up on demand :). Neither has hibernation enabled. I can't see any unusual events on the system which refuses to wake up. It just doesn't wake up, unless I do a manual wakeup or send it a wake-on-lan

Thread Delay using scheduler or Thread.Sleep

早过忘川 提交于 2021-01-27 10:51:37
问题 In my application I am calling third part vendor web-service. I need to delay my thread processing to achieve required throughput supported by vendor webservice. I have two options 1. Use Thread.Sleep 2. use ScheduledThreadPoolExecutor as mentioned in the post How to start a thread after specified time delay in java Wanted to know which is better option as we are sending time critical information(Text Message) using Vendor webservice. Any help is appreciated. 回答1: They're pretty much the same

Thread Delay using scheduler or Thread.Sleep

☆樱花仙子☆ 提交于 2021-01-27 10:48:55
问题 In my application I am calling third part vendor web-service. I need to delay my thread processing to achieve required throughput supported by vendor webservice. I have two options 1. Use Thread.Sleep 2. use ScheduledThreadPoolExecutor as mentioned in the post How to start a thread after specified time delay in java Wanted to know which is better option as we are sending time critical information(Text Message) using Vendor webservice. Any help is appreciated. 回答1: They're pretty much the same

Why are sleep function sleeps inconsistent?

岁酱吖の 提交于 2021-01-20 14:14:05
问题 import time from time import sleep from datetime import datetime while True: print datetime.now().strftime('%Y-%m-%d %H:%M:%S') sleep(1) It gives output 2018-09-23 16:14:42 2018-09-23 16:14:43 2018-09-23 16:14:44 2018-09-23 16:14:45 2018-09-23 16:14:46 2018-09-23 16:14:47 2018-09-23 16:14:48 2018-09-23 16:14:49 2018-09-23 16:14:50 2018-09-23 16:14:51 2018-09-23 16:14:53 2018-09-23 16:14:54 2018-09-23 16:14:55 2018-09-23 16:14:56 Skipped 52 second row. 回答1: Three reasons: time.sleep() is not

Why are sleep function sleeps inconsistent?

♀尐吖头ヾ 提交于 2021-01-20 14:11:27
问题 import time from time import sleep from datetime import datetime while True: print datetime.now().strftime('%Y-%m-%d %H:%M:%S') sleep(1) It gives output 2018-09-23 16:14:42 2018-09-23 16:14:43 2018-09-23 16:14:44 2018-09-23 16:14:45 2018-09-23 16:14:46 2018-09-23 16:14:47 2018-09-23 16:14:48 2018-09-23 16:14:49 2018-09-23 16:14:50 2018-09-23 16:14:51 2018-09-23 16:14:53 2018-09-23 16:14:54 2018-09-23 16:14:55 2018-09-23 16:14:56 Skipped 52 second row. 回答1: Three reasons: time.sleep() is not

Why are sleep function sleeps inconsistent?

蓝咒 提交于 2021-01-20 14:10:48
问题 import time from time import sleep from datetime import datetime while True: print datetime.now().strftime('%Y-%m-%d %H:%M:%S') sleep(1) It gives output 2018-09-23 16:14:42 2018-09-23 16:14:43 2018-09-23 16:14:44 2018-09-23 16:14:45 2018-09-23 16:14:46 2018-09-23 16:14:47 2018-09-23 16:14:48 2018-09-23 16:14:49 2018-09-23 16:14:50 2018-09-23 16:14:51 2018-09-23 16:14:53 2018-09-23 16:14:54 2018-09-23 16:14:55 2018-09-23 16:14:56 Skipped 52 second row. 回答1: Three reasons: time.sleep() is not

How to sleep or delay the thread in Haskell?

天大地大妈咪最大 提交于 2021-01-02 07:13:20
问题 This really shouldn't be so difficult to find an answer to, but alas I don't... I want to delay the next execution step in a do block. I have found the functions delay , sleep , nanosleep and usleep . And also this question, that doesn't cover how to use any of these, however: Sleep in Haskell. I am getting the same error for all of these, so probably I am doing something wrong fundamentally: Variable not in scope: delay :: Integer -> IO a0 This is my test snippet: main = do { putStrLn "line