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.
Asked
Active
Viewed 604 times
3

sjdowling
- 2,994
- 2
- 21
- 31

Magnus Kane
- 33
- 2
-
I suspect it's rather a winapi question than c++ – erenon Apr 20 '15 at 16:18
-
Just close (join) each thread one by one (how often are you doing it!?) – Apr 20 '15 at 16:19
1 Answers
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
-
-
1@DavidHeffernan: There is no easier either ;-) So it is the easiest *and* the only. – JensG Apr 20 '15 at 17:26