Matt Pascoe Matt Pascoe - 3 months ago 12
C++ Question

How do you add a timed delay to a C++ program?

I am trying to add a timed delay in a C++ program, and was wondering if anyone has any suggestions on what I can try or information I can look at?

I wish I had more details on how I am implementing this timed delay, but until I have more information on how to add a timed delay I am not sure on how I should even attempt to implement this.

Answer

Win32: Sleep(milliseconds) is what you what

unix: usleep(microseconds) is what you want.

sleep() only takes a number of seconds which is often too long.