3

Is there a way to close multiple handles to threads in C++ without having to close them individually? I have a few threads with handles that I have stored in an array so I can use WaitForMultipleObjects() before closing them. I know I could call CloseHandle on each handle in the array (either by loop or just one-by-one), but I was wondering if there was a simple way to close them all. Such as perhaps running CloseHandle on the array itself (if that would work)? Or does there exist a method along the lines of CloseMultipleHandles()? Thanks in advance.

sjdowling
  • 2,994
  • 2
  • 21
  • 31

1 Answers1

6

No. Loop and CloseHandle is the easiest solution. (Not that it's extremely difficult to implement...).

But then you can always create a CloseAllHandles function which takes an array of handles to close them...

Daniel
  • 1,041
  • 7
  • 13