VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

API Pause

Noëlhx  (1 Submission)   Windows API Call/Explanation   Visual Basic 5.0   Intermediate   Wed 3rd February 2021

Demonstrates how to pause in VB, without winding up the CPU, as While/Doevents/Wend code will do.

Inputs
Milliseconds to pause

Assumes
This uses the timeout feature of the WaitForSingleObject API call to break up a pause into smaller millisecond time chunks, allowing for a more responsive pause function. It also eliminates the CPU usage issue when using While/Doevents/Wend loops that make it hard to catchs problems. Since it does not do a comparison to the system clock, it mearly counts up milliseconds, there are no issues with midnight or clocks. You can change the resolution to suit your system. I have not submitted in a long time, so let me know if you would like more like this. Noel.

API Declarations
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA" (ByVal lpEventAttributes As Long, ByVal bManualReset As Long, ByVal bInitialState As Long, ByVal lpname As String) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Rate API Pause (6(6 Vote))

Download API Pause

API Pause Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters