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. SuspendThread & TerminateThread

SuspendThread & TerminateThread

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiohelpquestion
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.
  • M Offline
    M Offline
    Martijn van Kleef
    wrote on last edited by
    #1

    I find the VS help to be a little vague on this method, does SuspendThread halt execution of a thread -immediately-? And what if the thread contains some no-user-mode code? Can I use it to decently halt a thread before calling TerminateThread to brutally kill it? PS: I'm using TerminateThread because in one of my threads I'm calling into a function of a third-party lib (out of my control) that sometimes hangs. TerminateThread seems the only option left to stop the hanging (now threaded) function and retain control over application execution.

    N 1 Reply Last reply
    0
    • M Martijn van Kleef

      I find the VS help to be a little vague on this method, does SuspendThread halt execution of a thread -immediately-? And what if the thread contains some no-user-mode code? Can I use it to decently halt a thread before calling TerminateThread to brutally kill it? PS: I'm using TerminateThread because in one of my threads I'm calling into a function of a third-party lib (out of my control) that sometimes hangs. TerminateThread seems the only option left to stop the hanging (now threaded) function and retain control over application execution.

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      I don't know the answer to SuspendThread but I technique I find interesting and usefull to kill a thread is to force it to thow an exception. Have a look at http://www.codeproject.com/threads/threadlibrary.asp[^] which uses this technique. Hope that helps. Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com

      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