我想以毫秒为单位执行上述操作。我应该更喜欢哪个库和函数调用?
是的。
最佳答案
或者,如果您使用的是 Visual Studio 2010(或其他支持 c++0x 的编译器),请使用
#include <thread>
#include <chrono>
std::this_thread::sleep();
// or
std::this_thread::sleep_for(std::chrono::milliseconds(10));
对于较旧的编译器,您可以使用相关的 Boost Libraries 获得同样的便利。
不用说这里的主要好处是可移植性以及将延迟参数转换为“人类”单位的简便性。
关于c++ - C++ 中的 sleep 操作,平台 : windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7946092/