SuspendThread,暫停指定的執行緒。
基本介紹
- 中文名:執行緒暫停函式
- 外文名:SuspendThread
- 分 類:計算機 編程
- 來 源:微軟
- 頭檔案:WinBase.h
Parameters,Return value,Remarks,Requirements,
SuspendThread 函式
函式作用:暫停指定的執行緒(Suspends the specified thread.)
函式相關:在 64位套用中使用 Wow64SuspendThread函式
(A 64-bit application can suspend a WOW64 thread using the Wow64SuspendThread function)
WINAPI函式原型(C++):
DWORD WINAPI SuspendThread(
_In_HANDLE hThread
);
_In_HANDLE hThread
);
相關資料:
Parameters
- hThread [in]
- A handle to the thread that is to be suspended.
The handle must have the THREAD_SUSPEND_RESUME access right. For more information, see Thread Security and Access Rights.
Return value
If the function succeeds, the return value is the thread's previous suspend count; otherwise, it is (DWORD) -1. To get extended error information, use the GetLastError function.
Remarks
If the function succeeds, execution of the specified thread is suspended and the thread's suspend count is incremented. Suspending a thread causes the thread to stop executing user-mode (application) code.
This function is primarily designed for use by debuggers. It is not intended to be used for thread synchronization. Calling SuspendThread on a thread that owns a synchronization object, such as a mutex or critical section, can lead to a deadlock if the calling thread tries to obtain a synchronization object owned by a suspended thread. To avoid this situation, a thread within an application that is not a debugger should signal the other thread to suspend itself. The target thread must be designed to watch for this signal and respond appropriately.
Each thread has a suspend count (with a maximum value of MAXIMUM_SUSPEND_COUNT). If the suspend count is greater than zero, the thread is suspended; otherwise, the thread is not suspended and is eligible for execution. Calling SuspendThread causes the target thread's suspend count to be incremented. Attempting to increment past the maximum suspend count causes an error without incrementing the count.
The ResumeThread function decrements the suspend count of a suspended thread.
Windows Phone 8.1: This function is supported for Windows Phone Store apps on Windows Phone 8.1 and later.
Windows8.1 and Windows Server2012R2: This function is supported for Windows Store apps on Windows8.1, Windows Server2012R2, and later.
Requirements
Minimum supported client | WindowsXP [desktop apps only] |
---|---|
Minimum supported server | Windows Server2003 [desktop apps only] |
Minimum supported phone | Windows Phone 8.1 |
Header |
|
Library |
|
DLL |
|