Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

How to implement a microsecond resolution Delay

Title: How to implement a microsecond resolution Delay procedure PerformanceDelay; var hrRes, hrT1, hrT2, dif: Int64; begin if QueryPerformanceFrequency(hrRes) then begin QueryPerformanceCounter(hrT1); repeat QueryPerformanceCounter(hrT2); dif := (hrT2 - hrT1) * 10000000 div hrRes; until dif 2; end; end;