Questions tagged [thread-sleep]

The .net Thread.Sleep(...) method suspends the caller for a specified amount of time.

A call to Thread.Sleep(n) has no side effects, and it will not return until at least n milliseconds have elapsed.

References

815 questions
5
votes
1 answer

Create thread within DLL

I'm working on a .NET profiler which I'm writing in c++ (a dll that uses ATL). I want to create a thread that writes into a file every 30 seconds. I want the thread function to be a method of one of my classes DWORD WINAPI…
Kira
  • 1,153
  • 4
  • 28
  • 63
5
votes
3 answers

Swing - Thread.sleep() stop JTextField.setText() working

Possible Duplicate: using sleep() for a single thread I'm having issues with JTextField.setText() when using Thread.sleep(). This is for a basic calculator I'm making. When the input in the input field is not of the correct format I want "INPUT…
PElshen
  • 135
  • 1
  • 1
  • 10
5
votes
4 answers

using sleep() for a single thread

I am fairly new to java, and am starting to get into using different threads in order to use wait() or sleep() on one part of my code and have the others still run. For this project, I am using JFrame with the javax.swing.* and java.awt.* imports.…
Harper
  • 140
  • 2
  • 4
  • 10
5
votes
3 answers

Android: why i get these AsyncTask Error?

i have an asyncTaskProc that read some info from a DB and write it on the ui... the code works perfectcly on Android 4.0 but doesn't work on 2.3... here is the code NEW ASYNCTASK `public class IceCastPoll extends TimerTask { public IceCastPoll()…
radudac
  • 53
  • 1
  • 5
4
votes
4 answers

Java Thread.sleep leaking threads?

So I inherited a bit of code that's waiting for communication from a network source. While it's waiting for more data from the network socket, Thread.sleep(10) is called. This appears to be causing a thread leak, as reported by jconsole and my…
AWT
  • 3,657
  • 5
  • 32
  • 60
4
votes
4 answers

What might be the purpose of sleeping for just to see if the thread gets interrupted?

I came across some Java code that has a method containing the following: static boolean waitForSeconds(long seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException ex) { return false; } return…
Anonymous
  • 3,334
  • 3
  • 35
  • 50
4
votes
1 answer

Waiting for completion of one-way WCF call in a C# console application

I have a WCF webservice (not under my control) that implements functionality I need to access via IsOneWay=true + a callback interface, one of the methods of which notifies of processing completion. It has been written this way as it was initially…
anonymouse
  • 125
  • 1
  • 9
4
votes
1 answer

.NET Timers, do they fire at the exact interval or after processing + interval

So a simple enough question really. How exactly does the interval for System.Timers work? Does it fire 1 second, each second, regardless of how long the timeout event takes or does it require the routine to finish first and then restarts the…
Anthony
  • 441
  • 1
  • 5
  • 20
4
votes
2 answers

Pausing in C++ - Which Method?

I've noticed two different ways to "pause" in C++. (Though I think the proper name for it is sleeping.) Method 1, (probably the method most are familiar with): #include #include int main() { std::cout<<"Hello,…
Domani Tomlindo
  • 239
  • 1
  • 5
  • 12
4
votes
1 answer

How to cleanly sleep indefinitely?

A few threads are started in my code and I need at the end of the script to sleep indefinitely, without this sleep being a major hit on the performance1. One possibility can be to loop indefinitely with a short sleep: while True: …
WoJ
  • 27,165
  • 48
  • 180
  • 345
4
votes
1 answer

Reliable cross-platform way to obtain the method time in Java

This question is not about benchmark. I have a java thread cycle that should to operate close to a period time T: public class MyRunnable implements Runnable { private final long period = 10000L; //period T, in this case 10 secs public…
Duloren
  • 2,395
  • 1
  • 25
  • 36
4
votes
0 answers

Python sleep until time without busy loop

Let's say I want to make an event reminder in Python. It would read a file on startup containing a list of events (meetings, birthdays, etc), figure out which one is soonest, and then do something like time.sleep(1e7). Actually, that doesn't work:…
Mark VY
  • 1,489
  • 16
  • 31
4
votes
1 answer

Android: C++ thread not waking up if screen-locked or in background. Works fine when app is in use

In our Android app, we have UI component and core C++11 module. A thread is running based on std::chrono::system_clock::time_point, such as below: while(this->m_ConditionVariable.wait_until(lock, this->m_Object.to_time_point()) ==…
iammilind
  • 68,093
  • 33
  • 169
  • 336
4
votes
6 answers

How to stop code after Thread's sleep() method executing immediately

I have attempted to pause the execution of part of my program for a few seconds by invoking the sleep() method of the Thread class. However, when I try this, the code that comes immediately after this invocation still executes immediately. For…
lb91
  • 109
  • 9
4
votes
4 answers

How to correctly pause/delay Windows Forms application

I am a beginner to the OOP and the C#. I am working on a quiz game using the Windows Forms. My problem is related to two classes, the form and the game logic. I have a basic UI with classic Froms controls. Take a look. The thing I want to achieve…
user4870780