Found this little gem today. It is called in all the DDE-based functions in the unit. Nice.

Found this little gem today.  It is called in all the DDE-based functions in the unit.  Nice.

procedure DelayWithTimer(DelayTimeMSec: longint);
// Note: 1000 msec = 1 second
// New results (1gighertz): 12,500 ProcessMessages ~ 1 msec.
// Old results (100meghertz): 125 ProcessMessages ~ 1 msec.
// The smallest delay possible in this proc is 1 msec (10 msec in actuality).
var ii, StartTime, TimeNow : Longint;
begin
  StartTime := 0;
  if (DelayTimeMSec > 1) then StartTime := GetTheTimeMSEC; // Trick for 1 msec delay!
  repeat
    for ii := 1 to 12500 do Application.ProcessMessages;
    TimeNow := GetTheTimeMSEC;
  until (TimeNow > (StartTime+DelayTimeMSec)) or (TimeNow < StartTime);
end; // DelayWithTimer

Comments

  1. LOL! Where's the Tubo button... might need it in the near future!

    ReplyDelete
  2. What!? Wait. What!?!?!? Does this even work?

    ReplyDelete
  3. Dear Google! We need a FACEPALM+ button :D

    ReplyDelete
  4. must have been a reason for that at some point...

    ReplyDelete
  5. How many of these can you have active on one form before the setup implodes? Just a counter, a label, a button and a bit of time should be enough to find out.

    ReplyDelete
  6. Of all sick code you posted ever this one wins by far.

    ReplyDelete
  7. I realy like the comments, this function does not age well.

    ReplyDelete
  8. Must have been a rip-off from Microsoft's Windows 3.11 source code

    ReplyDelete
  9. Estimate this code was written circa 1996

    ReplyDelete

Post a Comment