• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

Sleep method

what is the effect of the Sleep method in delphi? is it safe to use?  thanks in advance!
0
dabestprogrammerindauniverse
Asked:
dabestprogrammerindauniverse
1 Solution
 
robert_marquardtCommented:
Your program will not get any CPU for the duration.
It is safe, only your messages arrive but do not get  handled (no CPU for you). In case of a timer this may get problematic for your program logic.
0
 
Lee_NoverCommented:
there are also other waiting methods
SleepEx, WaitForSingleObject, WaitForMultipleObcects
read about them in help :)
0
 
robert_marquardtCommented:
Yes, the difference is that these functions wait also (or only) for external events you requested.
0
 
AvonWyssCommented:
Sleep only suspends the THREAD which it is called from, not the whole application. Sleep is not a method (it is not bound to any object) but rather a procedure. Its use is safe virtually everywhere.
0
 
SteveWaiteCommented:
in a delphi application it only makes sense to use Sleep in a new thread. if u use sleep in e.g. form1 procedure then the app will appear to delay during that Sleep. user will notice app lock if moves window accros dewktop. the window freeses during Sleep
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now