SuspendThread

  DWORD SuspendThread(hThread)    
  HANDLE hThread;    

The SuspendThread function suspends a thread.

Parameters

hThread

Supplies a handle to the thread that is to be suspended. 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.

Comments

Suspending a thread causes the thread to stop executing user-mode (or application) code. 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 increment. Attempting to increment past the maximum suspend count causes an error without incrementing the count.

See Also

ResumeThread