This was always something I didn't like too much in AutoLisp. Officially you have 2 options:
- Use the delay command to pause execution
- Loop until the specified time has crept by
The first one isn't always possible - e.g. you might not want a command run at this time, or it's running in DBX?
The second one is probably the most accurate ... but I don't like it too much as it simply hogs the Lisp thread completely - which in turn is thus hogging the ACad thread. So if you're waiting for something to complete in ACad (say executed through send-string / send-command asynchronously) - this sort of "wait-while-time-not-elapsed" loop means that other command never gets any access to the CPU and would probably never complete.
Alternatives would be to make some ARX/DotNet lisp function which then uses a "true" sleep call. I.e. use something like an event or a thread instead of simply testing the time at each cycle the CPU has. But that means you need to then install and load such ARX/DLL in order to use it - not to mention it needs updating depending on the version of ACad.
Anyhow, what about using something available "for all" (well at least for most on Windows) ... VBScript has a Sleep function which does this. So then how to have AutoLisp make use of it? Unfortunately the Sleep function is a statement in VBS - not a method of some object VLisp can link to. So no direct calling of this is possible ... but what about "indirectly"? E.g.
(defun Sleep
(milliSecs
/ fn f start vbs
) (setq *Sleep:Error
* (+ *Sleep:Error
* (- (getvar 'millisecs
) start milliSecs
))))))