Mwahahah! Here's some example code that illustrates the idea...
You'll need a form with a single button, and the following code:
[tt]
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command3_Click()
Dim hThread As Long
Dim a As New Wombat
Dim b As New Wombat
Dim starttime As Long
' techniqe that blocks
starttime = GetTickCount
oResponse1 = a.FiveSecs
oResponse2 = b.TenSecs
Debug.Print GetTickCount - starttime
Debug.Print "Both calls now finished..."
oResponse1 = 0
oResponse2 = 0
' Horrendous thread-based technique that doesn't block...
starttime = GetTickCount
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf FiveSecs, ByVal 0&, ByVal 0&, 0&) ' hThreadID)
' Don't need handle, so dispose of it cleanly
CloseHandle hThread
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf TenSecs, ByVal 0&, ByVal 0&, 0&) ' hThreadID)
' Don't need handle, so dispose of it cleanly
CloseHandle hThread
Do Until oResponse1 <> 0 And oResponse2 <> 0
DoEvents
Loop
Debug.Print GetTickCount - starttime
Debug.Print "Both threads now finished..."
oResponse1 = 0
oResponse2 = 0
End Sub[/tt]
And a module containing the following:
[tt]
Option Explicit
Public Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public oResponse1 As Long
Public oResponse2 As Long
Public Sub FiveSecs()
Dim a As New Wombat
oResponse1 = a.FiveSecs
End Sub
Public Sub TenSecs()
Dim b As New Wombat
oResponse2 = b.TenSecs
End Sub[/tt]
And, for the example, a class module (my class is imaginatively called 'Wombat') with the following code:
[tt]
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Function TenSecs() As Long
Dim starttime As Long
starttime = GetTickCount
Do Until GetTickCount - starttime >= 10000
Loop
TenSecs = 10
End Function
Public Function FiveSecs() As Long
Dim starttime As Long
starttime = GetTickCount
Do Until GetTickCount - starttime >= 5000
Loop
FiveSecs = 5
End Function