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. SendMessage to Worker thread

SendMessage to Worker thread

Scheduled Pinned Locked Moved C / C++ / MFC
designquestion
7 Posts 5 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.
  • A Offline
    A Offline
    Ajay L D
    wrote on last edited by
    #1

    Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread? Thanks, AJ

    K S S T 4 Replies Last reply
    0
    • A Ajay L D

      Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread? Thanks, AJ

      K Offline
      K Offline
      kvrnkiran
      wrote on last edited by
      #2

      Yes. It is possible. Use PostThreadMessage. Hope that helps. Kiran.

      T 1 Reply Last reply
      0
      • A Ajay L D

        Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread? Thanks, AJ

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        I assume by the term "a message" you mean a message such as sent by the functions SendMessage, PostMessage, PostThreadMessage and friends. If so the answer is yes but there is a catch: the receiving thread must be running a message pump and in the case of thread messages it will have to be written accordingly.

        Steve

        1 Reply Last reply
        0
        • A Ajay L D

          Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread? Thanks, AJ

          S Offline
          S Offline
          SandipG
          wrote on last edited by
          #4

          Worker threads dont have MessagePump. So I dont think SendMessage,PostMessage or Post ThreadMessage will work. to send messages to worker threads you can try and use events.

          A 1 Reply Last reply
          0
          • S SandipG

            Worker threads dont have MessagePump. So I dont think SendMessage,PostMessage or Post ThreadMessage will work. to send messages to worker threads you can try and use events.

            A Offline
            A Offline
            Ajay L D
            wrote on last edited by
            #5

            Thanks! I also thought, unless you have a message pump in your thread...it is impossible to send any kind of message using the SendMessage call. As you told, we have to use some kind of synchronization objects. Thanks again, AJ

            1 Reply Last reply
            0
            • A Ajay L D

              Is it possible to send a message to a worker thread? I know we could send a message to a UI thread, but is the same possible with a worker thread? Thanks, AJ

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              Ajay L D wrote:

              I know we could send a message to a UI thread, but is the same possible with a worker thread?

              you have to setup message pump in the thread to handle message

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              • K kvrnkiran

                Yes. It is possible. Use PostThreadMessage. Hope that helps. Kiran.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                kvrnkiran wrote:

                Yes. It is possible. Use PostThreadMessage. Hope that helps.

                hi kiran, you have to setup message pump in the worker thread to process message send thorugh PostThreadMessage!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                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