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. THreads

THreads

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 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.
  • Y Offline
    Y Offline
    ykutanoor
    wrote on last edited by
    #1

    I have an app with 2 threads that run in background. Now I want to communicate between these threads. I know PostMessage would help ME. But I want to send a message from thread1 to therad 2 Pls help me with code snippet. Regards YKUTTANUR Chintu

    T P J 3 Replies Last reply
    0
    • Y ykutanoor

      I have an app with 2 threads that run in background. Now I want to communicate between these threads. I know PostMessage would help ME. But I want to send a message from thread1 to therad 2 Pls help me with code snippet. Regards YKUTTANUR Chintu

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      if they are really threads, you could use global datas ; if they in fact processes, use pipes or messages...


      TOXCCT >>> GEII power

      1 Reply Last reply
      0
      • Y ykutanoor

        I have an app with 2 threads that run in background. Now I want to communicate between these threads. I know PostMessage would help ME. But I want to send a message from thread1 to therad 2 Pls help me with code snippet. Regards YKUTTANUR Chintu

        P Offline
        P Offline
        Prakash Nadar
        wrote on last edited by
        #3

        ykutanoor wrote: I know PostMessage would help ME. But I want to send a message from thread1 to therad 2 Pls help me with code snippet. are you looking for PostThreadMessage(...)


        God is Real, unless declared Integer.

        1 Reply Last reply
        0
        • Y ykutanoor

          I have an app with 2 threads that run in background. Now I want to communicate between these threads. I know PostMessage would help ME. But I want to send a message from thread1 to therad 2 Pls help me with code snippet. Regards YKUTTANUR Chintu

          J Offline
          J Offline
          Jitendra gangwar
          wrote on last edited by
          #4

          1. Put this code in both the thread code that is required for the Examining a Message Queue that is associated with a particaular thread. BOOL fDone; MSG msg; // Begin the operation and continue until it is complete fDone = FALSE; while (!fDone) { fDone = DoLengthyOperation(); // application-defined function // Remove any messages that may be in the queue. If the // queue contains any mouse or keyboard // messages, end the operation. while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch(msg.message) { case WM_USER1: case WM_USER2: // // Perform any required cleanup. // fDone = TRUE; } } } 2. Use the PostThreadMessage(....) API for posting the messages between threads. Jitendra

          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