Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MultiThread question?

MultiThread question?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    G_S
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • G 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

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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

      G 1 Reply Last reply
      0
      • M Michael Dunn

        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

        G Offline
        G Offline
        G_S
        wrote on last edited by
        #3

        Thanks for the quick response. G_S

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups