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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Threads and ~Component

Threads and ~Component

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
2 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.
  • P Offline
    P Offline
    Paul Farry
    wrote on last edited by
    #1

    I've got a component which uses a library which MUST be properly closed when you exit from using it. It takes a couple of seconds. Is it ok to create a Thread to do all this work (as long as I don't modify or read memory inside the component from within the thread) in the Destructor of the component? And exit the component immediately?

    R 1 Reply Last reply
    0
    • P Paul Farry

      I've got a component which uses a library which MUST be properly closed when you exit from using it. It takes a couple of seconds. Is it ok to create a Thread to do all this work (as long as I don't modify or read memory inside the component from within the thread) in the Destructor of the component? And exit the component immediately?

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      Paul Farry wrote: Is it ok to create a Thread to do all this work (as long as I don't modify or read memory inside the component from within the thread) in the Destructor of the component? Yes, it's fine. As you mentioned, watch out for accessing memory that has been deleted.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      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