Talk:System.DateUtils.MilliSecondsBetween

From RAD Studio API Documentation
Jump to: navigation, search

In some situations where you want to wait for N milliseconds before going on to the next step, using MilliSecondsBetween will fail to give the desired result. This tends to be situations where Windows Message processing is critical to the behavior.

As an alternative to DateUtils.MilliSecondsBetween, you can use Windows.GetTickCount() instead of Now(), and compare the number of milliseconds with a function such as the following. This will avoid the problem.


function MilliSecondsBetweenTicks(const TickA, TickB: Cardinal): Cardinal; begin

 Result := Cardinal(Int64(TickA) - Int64(TickB));

end;

Thank you for your input! Your suggestion has been added to our work queue. -- Denisa Tibeica