我们可以直接在VS2010 C ++中使用sleep()吗?

问题描述:

我正在尝试将VS2010 C ++中的sleep()函数用作延迟函数.
但是我发现它不起作用.

I am trying to use sleep() function in VS2010 C++ as a delay function.
But I find it doesn''t work.

^ ]当然可以,尽管通常是错误的解决方案:)

使用睡眠的一些规则

1.永远不要在UI线程上执行此操作
2.不要使用睡眠,请等待对象
3.参见#2
Sleep(DWORD)[^] certainly works, though it''s normally the wrong solution :)

A few rules of using Sleep

1. Don''t ever do it on the UI thread
2. Don''t use Sleep, wait on an object
3. See #2