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

PostThreadMessage

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformancedata-structuresquestion
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.
  • W Offline
    W Offline
    wilche
    wrote on last edited by
    #1

    Recently, I wrote on message board, that I had problem PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. The bug disappear when I used: Sleep(20); to force it sleep for 20 ms. But when I tested it using larger test data, the same problem occurred, even more serious then before. Furthermore the performance eroded to point that it was better off not using threads. In both cases, resources was critically reduced. The "apparent" culprit was that the low resources. As the rate messages entering the message queue was higher than it's removal through processing, net increase in queue. Each message can contain significant amounts of data (up to 20k) and hence low resources. I have checked carefully there is no memory leakage so this was the only conclusion I could draw. Closer study also showed that SendMessage also failed under these circumstances. What I want to ask, 1, Has anyone else had this sort of problem? 2, Is my conclusion correct? 3, Is there a fix for this? Thank you! Any reply is greatly appreciated Kind regards, wilche :) The more simple things are, the more complex is the way it works. The more complex things are, there is probably a simpler solution.

    R 1 Reply Last reply
    0
    • W wilche

      Recently, I wrote on message board, that I had problem PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. The bug disappear when I used: Sleep(20); to force it sleep for 20 ms. But when I tested it using larger test data, the same problem occurred, even more serious then before. Furthermore the performance eroded to point that it was better off not using threads. In both cases, resources was critically reduced. The "apparent" culprit was that the low resources. As the rate messages entering the message queue was higher than it's removal through processing, net increase in queue. Each message can contain significant amounts of data (up to 20k) and hence low resources. I have checked carefully there is no memory leakage so this was the only conclusion I could draw. Closer study also showed that SendMessage also failed under these circumstances. What I want to ask, 1, Has anyone else had this sort of problem? 2, Is my conclusion correct? 3, Is there a fix for this? Thank you! Any reply is greatly appreciated Kind regards, wilche :) The more simple things are, the more complex is the way it works. The more complex things are, there is probably a simpler solution.

      R Offline
      R Offline
      Rama Krishna Vavilala
      wrote on last edited by
      #2

      wilche wrote: PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. Does the thread in question has it's message queue created. That is does it call any of GetMessage, PeekMessage etc. functions before you call PostThreadMessage from other threads. That might be the problem.

      W 1 Reply Last reply
      0
      • R Rama Krishna Vavilala

        wilche wrote: PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. Does the thread in question has it's message queue created. That is does it call any of GetMessage, PeekMessage etc. functions before you call PostThreadMessage from other threads. That might be the problem.

        W Offline
        W Offline
        wilche
        wrote on last edited by
        #3

        Sorry my fault, I have made sure that the message queue has been created properly. This is because the messages inside the queue were correctly being processed. Thanks for picking this up! wilche

        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