VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



API Pause

by Noëlhx (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

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

Download API Pause

Download API Pause (3 KB)

API Pause Comments

No comments have been posted about API Pause. Why not be the first to post a comment about API Pause.

Post your comment

Subject:
Message:
0/1000 characters