SetThreadName

Assigns a name to a thread.

Syntax

BOOL SetThreadName(
         HANDLE hThread,
         PWSTR lpThreadName
)  

Parameters

hThread
Type: HANDLE 

[in] A HANDLE for the thread whose name should be set.

lpThreadName
Type: PWSTR 

[in] The name to assign to the thread.

Return value

Type: BOOL 

Indicates whether the name was successfully assigned to the thread. If the function succeeds the return value is TRUE. If the function fails, the return value is FALSE.

Remarks

Assigning a name to a thread makes it much easier to identify the thread in development tools like PIX. A thread’s name can be retrieved using GetThreadName.

Example

BOOL success = SetThreadName(GetCurrentThread(), L"Simulation_thread"); 
if (!success) 
{ 
  // call failed 
}  

Requirements

Header: Declared in minwinbase.h.

Library: Use toolhelpx.lib.