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. Size of the Message loop

Size of the Message loop

Scheduled Pinned Locked Moved C / C++ / MFC
data-structurestutorial
10 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.
  • V Offline
    V Offline
    vc _fragrance
    wrote on last edited by
    #1

    Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.

    C L R 3 Replies Last reply
    0
    • V vc _fragrance

      Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      From PostMessage function documentation on MSDN [^]:

      There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.

      HKEY_LOCAL_MACHINE
      SOFTWARE
      Microsoft
      Windows NT
      CurrentVersion
      Windows
      USERPostMessageLimit

      The minimum acceptable value is 4000.

      :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      L C 2 Replies Last reply
      0
      • V vc _fragrance

        Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        vc++_fragrance wrote:

        1)How to handle the scenario... so that my application should not crash.

        Your message loop should take care of this by processing every message on the queue. Only if the loop does not handle the messages is this likely to happen.

        vc++_fragrance wrote:

        1. How to find the size of the Message queue.

        I'm not sure if this information is available, but you could check the MSDN documentation[^] for further information.

        1 Reply Last reply
        0
        • C CPallini

          From PostMessage function documentation on MSDN [^]:

          There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.

          HKEY_LOCAL_MACHINE
          SOFTWARE
          Microsoft
          Windows NT
          CurrentVersion
          Windows
          USERPostMessageLimit

          The minimum acceptable value is 4000.

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Trust Microsoft to put this detail in the one function that I did not look at just now. :mad:

          C 1 Reply Last reply
          0
          • L Lost User

            Trust Microsoft to put this detail in the one function that I did not look at just now. :mad:

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            You should subscribe, like I did, the 'immediately informed by Microsoft about' neewsletter. :-D BTW: Merry Christmas!!! :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            L 1 Reply Last reply
            0
            • C CPallini

              You should subscribe, like I did, the 'immediately informed by Microsoft about' neewsletter. :-D BTW: Merry Christmas!!! :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Thanks for the tip, I'll give it a try. And Merry Christmas to you also.

              1 Reply Last reply
              0
              • C CPallini

                From PostMessage function documentation on MSDN [^]:

                There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.

                HKEY_LOCAL_MACHINE
                SOFTWARE
                Microsoft
                Windows NT
                CurrentVersion
                Windows
                USERPostMessageLimit

                The minimum acceptable value is 4000.

                :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                C Offline
                C Offline
                Chris Meech
                wrote on last edited by
                #7

                Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem. :) Happy Holidays to everyone.

                Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                R 1 Reply Last reply
                0
                • V vc _fragrance

                  Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #8

                  Either SendMessage can be used, or if you're afraid of the sender being taken into a deadlock, consider SendMessageTimeout[^] But more importantly, why is it that your DLL needs to continuously raise events and clobber the message queue? May be if you could explain your scenario, someone here might be able to suggest a better alternative. I say it because if you increase the message queue size on one computer, your program will still not work on another computer whose message queue size is the default! This is not a pretty sight.

                  “Follow your bliss.” – Joseph Campbell

                  1 Reply Last reply
                  0
                  • C Chris Meech

                    Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem. :) Happy Holidays to everyone.

                    Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    Chris Meech wrote:

                    Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem.

                    Good Lord, so you've worked with that sort of horrendous applications? (I'm into that club too and I ended up rewriting an app once) BTW, Merry Christmas to you!

                    “Follow your bliss.” – Joseph Campbell

                    C 1 Reply Last reply
                    0
                    • R Rajesh R Subramanian

                      Chris Meech wrote:

                      Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem.

                      Good Lord, so you've worked with that sort of horrendous applications? (I'm into that club too and I ended up rewriting an app once) BTW, Merry Christmas to you!

                      “Follow your bliss.” – Joseph Campbell

                      C Offline
                      C Offline
                      Chris Meech
                      wrote on last edited by
                      #10

                      I have worker thread classes that query a database and post registered messages to controls. The loop that posts always seems to run faster than the UI thread can process. So I use a lock to throttle the worker thread when this happens. It was a difficult bug to deal with. :)

                      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                      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