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. How to notify one thread to terminate

How to notify one thread to terminate

Scheduled Pinned Locked Moved C / C++ / MFC
questiondesigndata-structurestutorialcareer
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.
  • J Offline
    J Offline
    Jin Yao
    wrote on last edited by
    #1

    Hello all, I want to notify thread1 to end by itself. I don't like to use the function TerminateThread() to do this job. But thread1 is a worker thread not a UI thread so it doesn't have a message queue. I can't send some messages to it. How can I do? Thanks a lot

    D 1 Reply Last reply
    0
    • J Jin Yao

      Hello all, I want to notify thread1 to end by itself. I don't like to use the function TerminateThread() to do this job. But thread1 is a worker thread not a UI thread so it doesn't have a message queue. I can't send some messages to it. How can I do? Thanks a lot

      D Offline
      D Offline
      Dudi Avramov
      wrote on last edited by
      #2

      Well, if the worker thread waits for an event with WaitForSingleObject then add one more event for quit event and then set that event by using SetEvent. The thread should wait for signal from one of the both events by using WaitForMultipleObjects API.

      J 1 Reply Last reply
      0
      • D Dudi Avramov

        Well, if the worker thread waits for an event with WaitForSingleObject then add one more event for quit event and then set that event by using SetEvent. The thread should wait for signal from one of the both events by using WaitForMultipleObjects API.

        J Offline
        J Offline
        Jin Yao
        wrote on last edited by
        #3

        Thanks Dudi, I get an idea now.

        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