网站首页  词典首页

请输入您要查询的函数:

 

术语 sleep
释义 Sleep
语法:
C++
VOID WINAPI Sleep(
__in DWORD dwMilliseconds
);
睡眠功能
暂停时间直到当前线程执行超时间隔经过的。
要输入一个报警等待状态,请使用SleepEx功能。
参数
dwMilliseconds的 [in]
时间间隔的执行被暂停以毫秒为单位。
值为零会导致线程放弃其剩余的时间片同等优先的任何其他线程准备运行。如果有一个平等的优先权没有现成的其他线程运行,函数立即返回,并继续执行线程。
无限的值表示暂时不要超时。
返回值
这个函数没有返回值。
备注
这个函数导致线程放弃其剩余的时间片,并成为对dwMilliseconds的值为基础的间隔unrunnable。该系统时钟“滴答”,以恒定速率。如果dwMilliseconds的比对系统时钟的决议,则该线程可能睡眠的时间超过了规定的长度。如果dwMilliseconds的大于一剔,但不超过两分,等待可以在任何地方一至二扁虱等。为了增加睡眠时间间隔的准确性,调用timeGetDevCaps函数来确定支持的最低计时器决议和timeBeginPeriod函数来设置计时器分辨率最低限度。使用时要小心调用timeBeginPeriod,例如经常调用可以极大地影响系统时钟,系统功耗和调度。如果您调用timeBeginPeriod,称之为一次在应用初期,并务必调用应用程序非常结束timeEndPeriod功能。
睡眠时间间隔后,已通过,线程准备运行。如果指定0毫秒,线程将放弃其剩余时间片,但仍准备。请注意,一个现成的线程不能保证立即运行。因此,线程可能无法运行,直到一些睡眠时间间隔后,经过的时间。有关更多信息,请参阅调度优先级。
使用时要小心睡眠和代码直接或间接产生的窗口。如果一个线程创建的窗口,它必须处理消息。广播消息发送到系统中的所有窗口。如果您有一个线程使用具有无穷时滞睡眠,系统将僵局。两个代码,间接创造DDE的窗口和COM CoInitialize例子。因此,如果您有一个线程创建的窗口,使用,而非睡眠MsgWaitForMultipleObjects或MsgWaitForMultipleObjectsEx。
实例
有关示例,请参阅使用线程本地存储。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
MsgWaitForMultipleObjects
MsgWaitForMultipleObjectsEx
进程和线程函数
SleepEx
暂停线程的执行
主题
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==Sleep Function
Suspends the execution of the current thread until the time-out interval elapses.
To enter an alertable wait state, use the SleepEx function.
Syntax
C++
VOID WINAPI Sleep(
__in DWORD dwMilliseconds
);
Parameters
dwMilliseconds [in]
The time interval for which execution is to be suspended, in milliseconds.
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.
A value of INFINITE indicates that the suspension should not time out.
Return Value
This function does not return a value.
Remarks
This function causes a thread to relinquish the remainder of its time slice and become unrunnable for an interval based on the value of dwMilliseconds. The system clock "ticks" at a constant rate. If dwMilliseconds is less than the resolution of the system clock, the thread may sleep for less than the specified length of time. If dwMilliseconds is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on. To increase the accuracy of the sleep interval, call the timeGetDevCaps function to determine the supported minimum timer resolution and the timeBeginPeriod function to set the timer resolution to its minimum. Use caution when calling timeBeginPeriod, as frequent calls can significantly affect the system clock, system power usage, and the scheduler. If you call timeBeginPeriod, call it one time early in the application and be sure to call the timeEndPeriod function at the very end of the application.
After the sleep interval has passed, the thread is ready to run. If you specify 0 milliseconds, the thread will relinquish the remainder of its time slice but remain ready. Note that a ready thread is not guaranteed to run immediately. Consequently, the thread may not run until some time after the sleep interval elapses. For more information, see Scheduling Priorities .
Be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx , rather than Sleep.
Examples
For an example, see Using Thread Local Storage .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
MsgWaitForMultipleObjects
MsgWaitForMultipleObjectsEx
Process and Thread Functions
SleepEx
Suspending Thread Execution
Threads
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686298(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:26:40