The human context of quality

Improved timer function

Posted on 2009-Feb-5 at 10:49

The timer function I posted last week has an issue in that the call to Exist(0) does not always return immediately. Here is an updated version that uses a MercuryTimer object to use elapsed time rather than number of loops. It is based on the article by Meir Bar-Tal posted here.

Public Function WaitUntilObjectFound(ByRef obj, ByVal intTimeoutSec)
 Dim objTimer, intTimeoutMSec
 intTimeoutMSec = intTimeoutSec * 1000
 Set objTimer = MercuryTimers.Timer("ObjectExist")    
 objTimer.Start    
 Do
  WaitUntilObjectFound = obj.Exist(0)       
  If WaitUntilObjectFound Then           
   objTimer.Stop           
   Exit Do       
  End If       
  Wait 1
 Loop Until objTimer.ElapsedTime > intTimeoutMSec   
 objTimer.Stop
End Function


Last Page | Page 13 of 15 | Next Page
To realize that you do not understand is a virtue; Not to realize that you do not understand is a defect.
Lao Tzu

Friends