ResumeThread

  DWORD ResumeThread(hThread)    
  HANDLE hThread; /* identifies the thread to restart */

The ResumeThread function decrements a thread's suspend count. If the suspend count is decremented to zero, the thread starts running.

Parameters

hThread

Specifies a handle for the thread to restart. The handle must have been created with THREAD_SUSPEND_RESUME access to the thread.

Return Value

The return value is the thread's previous suspend count if the function is successful, or -1 if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The ResumeThread function checks the suspend count of the subject thread. If the suspend count is zero, the thread is not currently suspended. Otherwise, the subject thread's suspend count is decremented. If the resultant value is zero, then the execution of the subject thread is resumed.

If the return value is zero, the specified thread was not suspended. If the return value is one, the specified thread was suspended but was restarted. If the return value is greater than one, the specified thread is still suspended; the ResumeThread function must be called the return value minus one times before the thread will actually start running.

Note that while reporting debug events, all threads within the reporting process are frozen. Debuggers are expected to use the SuspendThread and ResumeThread functions to limit the set of threads that can execute within a process. By suspending all threads in a process except for the one reporting a debug event, it is possible to “single step” a single thread. The other threads will not be released by a continue if they are suspended.

See Also

SuspendThread