c++multithreadingwinapi

How to change the name of a thread


I have a server application that uses "a lot" of threads. Without wanting to get into an argument about how many threads it really should be using, it would be nice to be able to see some descriptive text in the debugger "threads" window describing what each one is, without having to click through to it and determine from the context what it is.

They all have the same start address so generally the threads window says something like "thread_base::start" or something similar. I'd like to know if there is an API call or something that allows me to customise that text.


Solution

  • You can use the SetThreadDescription defined here or the SetThreadName function defined on the same page.