MultiThread question?
-
The problem i'm having is this CreateThread returns a handle to the thread the handle is not needed but even after the thread dies the handle seams still to exist so i did the folowing. CloseHandle ( CreateThread(....) ); could this become a problem now in future and past verions of windows? Simply to ignore it is not an options since houerly there might be 100's of trheads. G_S
-
The problem i'm having is this CreateThread returns a handle to the thread the handle is not needed but even after the thread dies the handle seams still to exist so i did the folowing. CloseHandle ( CreateThread(....) ); could this become a problem now in future and past verions of windows? Simply to ignore it is not an options since houerly there might be 100's of trheads. G_S
Well, you shouldn't do that code exactly because you need to check the return value from
CreateThread()
to see if it succeeded. If it does succeed, it returns a handle to the thread object in the kernel. If you don't need to use that handle, you can close it right away. You're right in that you shouldn't ignore it, because objects with open handles can't be destroyed, and will fill up your app's process space.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Well, you shouldn't do that code exactly because you need to check the return value from
CreateThread()
to see if it succeeded. If it does succeed, it returns a handle to the thread object in the kernel. If you don't need to use that handle, you can close it right away. You're right in that you shouldn't ignore it, because objects with open handles can't be destroyed, and will fill up your app's process space.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ