[API]
FILETIME
CreateWaitableTimerA
CreateWaitableTimerW
SetWaitableTimer
MsgWaitForMultipleObjects
CloseHandle

[DEFINE]
Private Const SleepValueHigh As Long = 100&
Private Const SleepValueLow As Long = 25&

[CODE]
Public Sub DoEventsEx_Sleep(ByVal IntervalMS As Long)
  Dim xType1 As FILETIME
  Dim xLong1 As Long

  If IsUnicode Then
    xLong1 = CreateWaitableTimerW(0, True, 0&)
    Else
    xLong1 = CreateWaitableTimerA(0, True, 0&)
    End If
  xType1.dwLowDateTime = -1&
  xType1.dwHighDateTime = -1&
  Call SetWaitableTimer(xLong1, xType1, 0&, 0&, 0&, 0&)
  xType1.dwLowDateTime = IntervalMS * -10000&
  Call SetWaitableTimer(xLong1, xType1, 0&, 0&, 0&, False)
  Do Until MsgWaitForMultipleObjects(1&, xLong1, False, -1&, 255&) = 0&
    DoEvents
    Loop
  DoEvents
  Call CloseHandle(xLong1)
  End Sub
