SuspendThread (Compact 2013)

3/28/2014

This function suspends the specified thread.

Syntax

DWORD SuspendThread(
  HANDLE hThread
); 

Parameters

  • hThread
    [in] Handle to the thread.

Return Value

The previous suspend count of the thread indicates success.

The following values indicate failure:

Return value

Description

0xFFFFFFFE

The thread will not be suspended due to one of the following conditions:

  • The provided handle specified a thread that is in the process of terminating.
  • The provided handle specified a kernel thread.
  • The provided handle was not a valid thread handle.

0xFFFFFFFF

All other errors.

To get extended error information, call GetLastError.

Remarks

If the function succeeds, execution of the specified thread is suspended. Suspending a thread causes the thread to stop executing user-mode (application) code.

Each thread has a 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. The suspend count has a maximum value of MAXIMUM_SUSPEND_COUNT.

Calling SuspendThread successfully causes the target thread's suspend count to be incremented. Attempting to increment past the maximum suspend count causes an error and does not increment the suspend count. The ResumeThread function decrements the suspend count of a suspended thread.

If a user-mode thread is currently executing code in a PSL server, SuspendThread will return 0 and mark the thread to be suspended when the thread returns from the PSL call.

Calling SuspendThread on a kernel thread does not suspend the thread.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

Process and Thread Functions
ResumeThread