How to delay about 1/20 milisecond ?
-
hai do u know assmbly language. if u know 8086 assm lan Easily you can create a time delay
-
You probably can't reliably without going to extrodinary means. This is because Windows is not a Real time operating system, and at any stage your process could be preempted. However, the closest you can get is by calling ::Sleep(20) In reality this will sleep more than twenty milliseconds quite often, because it relinquishes your timeslice in the process scheduler, but it is the best you can do without doing something really hard. Despite what my mis-spelling co-poster tells you, going to assembly language will not offer you any benefit over the above, because it is no less subject to pre-emption than anything else. He/she might argue that you do not relinquish your timeslice as above, however the same can be accomplished in C++ too. For example: class Timer { public: Timer(); void wait(DWORD ms); private: static int cyclesPerMs; // Number of loop iterations per millisecond }; int Timer::cyclesPerMs = -1; Timer::Timer() { const CALIBRATION_TICKS = 100000; if(cyclesPerMs == -1) { // Calibrate timer clock_t start = clock(); for(int i=0; i
-
What do you need the delay for? Don't try it, just do it! ;-)