No CPU Load - SafeSleep
The *BEST* way to safely Sleep/Pause without taxing the CPU.
Original Author: Steve Gaeke
Code
The two functions below both sleep for the specified number of seconds. However, the popular code seen in the BusySleep procedure actually causes the CPU load to stay near 100% until complete. The SafeSleep routine pauses without taxing the CPU and stays at nearly 0% CPU.
Both functions take a single value so you can sleep for fractions of a second.
Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Long, pHandles As Long, ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, ByVal dwWakeMask As Long) As Long
Public Sub SafeSleep(ByVal inWaitSeconds As Single)
End Sub
Public Sub BusySleep(ByVal inWaitSeconds As Single)
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.