(The M_XXXX_ASYNC function called should return "Loading.." until its done) This does not work. VBA does pass the control back to Excel (in DoEvents), but the cell's result is not updated until the max timeout of 10 seconds expires. The async function should have finished way before 10 secs.
Sub test_async()
Dim timeout As Double, maxWait As Double
timeout = 0.1
maxWait = 10
StartTime = Timer
Range("b5").Formula = "=M_XXXX_ASYNC(" + Chr(34) + "some_argument_here" + Chr(34) + ")"
KeepWaiting:
StartPause = Timer
Do Until Timer >= StartPause + timeout
DoEvents
Loop
If Left(Range("b5").Value, 7) = "Loading" And Timer < StartTime + maxWait Then
GoTo KeepWaiting
End If
MsgBox "Loaded: " + CStr(result)
End Sub
Is there a way to achieve what I want?