Its very important to know that the value can exceed the $80000000. That means
you'll get negativ results. If you use it in this way (see below), your programm will
hang after some time...
Code: Select all
Procedure ElapsedMilliseconds_()
; Simulate a long uptime
ProcedureReturn ElapsedMilliseconds() + $80000000
EndProcedure
Procedure WaitForTimeOut_1 ()
Protected TimeOut.i = ElapsedMilliseconds() + 5000
; Wait 5 Sec. for e.g. a Thread has finished
Repeat
If Random(10) = 5
TimeOut = #Null
; Thread has finished, Set Timeout to #Null to leave loop now
Debug "Done"
Else
Delay(100)
EndIf
Until TimeOut < ElapsedMilliseconds()
Debug "WaitForTimeOut_1 done"
EndProcedure
Procedure WaitForTimeOut_2 ()
Protected TimeOut.i = ElapsedMilliseconds_() + 5000
; Wait 5 Sec. for e.g. a Thread has finished
Repeat
If Random(10) = 5
TimeOut = #Null
; Thread has finished, Set Timeout to #Null to leave loop now
Debug "Done"
Else
Delay(100)
EndIf
Until TimeOut < ElapsedMilliseconds_()
Debug "WaitForTimeOut_2 done"
EndProcedure
; This will work, if your computer have a short uptime
Debug WaitForTimeOut_1()
; Simulate a long uptime, the timeout check does not work in this way
Debug WaitForTimeOut_2()