ResumeThread
BOOL ResumeThread( HANDLE hThread );
Parameters
| Parameter | Description |
|---|---|
| hThread | A handle to the thread to be resumed. This handle must have the THREAD_SUSPEND_RESUME access right. |
Return value
If the function succeeds, the return value is the thread's previous suspension count. If the function fails, the return value is 0xFFFFFFFF. To get extended error information, call GetLastError.
Remarks
The ResumeThread function increments the suspension count for the specified thread. If the suspension count becomes zero, the thread is transitioned from a suspended state to a runnable state. Otherwise, the thread remains suspended.
A thread's suspension count is a value between 0 and 1024, inclusive. The system limits the suspension count to prevent a thread from being suspended indefinitely.
If ResumeThread succeeds, the return value is the thread's suspension count before the call to ResumeThread. This is useful for applications that suspend a thread multiple times. The application must call ResumeThread the same number of times to resume the thread.
Example
HANDLE hThread = CreateThread( NULL, // Default security attributes
0, // Default stack size
MyThreadFunction, // Thread function
NULL, // Parameter to thread function
CREATE_SUSPENDED, // Creation flag
NULL // Thread identifier
);
if (hThread != NULL) {
// Resume the thread
DWORD suspendCount = ResumeThread(hThread);
if (suspendCount == 0xFFFFFFFF) {
// Handle error
printf("Error resuming thread: %lu\n", GetLastError());
} else {
printf("Thread resumed. Previous suspension count: %lu\n", suspendCount);
// The thread will now start execution or continue if it was already running and suspended
}
// Close the thread handle when done
CloseHandle(hThread);
}
Requirements
| Attribute | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | processthreadsapi.h (include Windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |