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. Worker Thread notification in the middle.

Worker Thread notification in the middle.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 4 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.
  • U Offline
    U Offline
    User 1751033
    wrote on last edited by
    #1

    Hi, A worker thread is running the threadproc. While it is running i want to send some data to it from main thread. How to do this? Thanks in advance. jagadeesh

    E A D 4 Replies Last reply
    0
    • U User 1751033

      Hi, A worker thread is running the threadproc. While it is running i want to send some data to it from main thread. How to do this? Thanks in advance. jagadeesh

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #2

      wat kind of data? v

      1 Reply Last reply
      0
      • U User 1751033

        Hi, A worker thread is running the threadproc. While it is running i want to send some data to it from main thread. How to do this? Thanks in advance. jagadeesh

        A Offline
        A Offline
        Abebe
        wrote on last edited by
        #3

        There are several methods to do this: 1) Use a global variable that stores the data you want to send to the worker thread; 2) Use a singleton; 3) Use files; I'd go with a singleton, that seems the be the most 'clean'. Remember to synchronise your data, since it will most likely be accessed by multiple threads (avoid corrupt data!). There are probably some other methods you can use. Er zit een korstje op mijn aars.

        1 Reply Last reply
        0
        • U User 1751033

          Hi, A worker thread is running the threadproc. While it is running i want to send some data to it from main thread. How to do this? Thanks in advance. jagadeesh

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          using Global variabe works simply..... v

          1 Reply Last reply
          0
          • U User 1751033

            Hi, A worker thread is running the threadproc. While it is running i want to send some data to it from main thread. How to do this? Thanks in advance. jagadeesh

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Since the thread does not have a message pump, using PostMessage() is out of the question. I think you are left with synchronization and events at this point.


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            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