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. What can cause SendMessage to get stuck?

What can cause SendMessage to get stuck?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
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.
  • S Offline
    S Offline
    skyapie
    wrote on last edited by
    #1

    Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D

    J D PJ ArendsP 3 Replies Last reply
    0
    • S skyapie

      Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D

      J Offline
      J Offline
      Jonathan Darka
      wrote on last edited by
      #2

      Its called a deadlock and your thread synchronisation is not working correctly, SendMessage() will wait until the message has been processed before returning, you could try PostMessage() instead which will not wait but I would check your thread synchronisation first.


      Darka [Xanya] "I am not a slave to a god that doesn't exist."

      1 Reply Last reply
      0
      • S skyapie

        Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D

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

        skyapie wrote:

        I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI.

        Secondary threads should post messages (i.e., PostMessage()) to the primary thread.


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • S skyapie

          Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          As has been said, never use SendMessage() to send messages between threads. Use PostMessage() instead. If you really need the return value from the message then you can use SendMessageTimeout().


          You may be right
          I may be crazy
          -- Billy Joel --

          Within you lies the power for good, use it!!!

          Within you lies the power for good; Use it!

          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