1

I'd like to set names to my threads in VS, to ease debugging. This can be set using special exception - How to set name to a Win32 Thread?. However, debugger has to be already attached at the time given exception is thrown.

Is there any possibility to register for an event, when debugger is attached? (I don't want to be checking IsDebuggerPresent every time). I'd throw given 'name my thread' exception in that case.

Community
  • 1
  • 1
nothrow
  • 15,882
  • 9
  • 57
  • 104
  • No debugger has to be attached. That's why the RaiseException() is in a __try block. And no, there is no event. – Hans Passant Feb 09 '14 at 15:44
  • @HansPassant, if the debugger is not attached, that call does nothing, but I'd like to see names when I attach it. – nothrow Feb 09 '14 at 17:53
  • That's true. There still is no event. You'd have to add your own, maybe a hotkey. You'll surely find it quite difficult to get the thread to actually notice it. Which for one explains why there is no event :) – Hans Passant Feb 09 '14 at 17:56
  • @HansPassant, thanks. I know it would be difficult, that's why I thought OS is able to give the application some 'hint' :) Can you use your last comment as an answer, so I can mark this question answered? – nothrow Feb 10 '14 at 12:41

1 Answers1

1

On Windows, there is no such event.

nothrow
  • 15,882
  • 9
  • 57
  • 104