SendMessage API question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abubakar

    SendMessage API question

    Hi,
    in my application, different threads send notifications to GUI thread
    through sendmessage api. They have special integer numbers inside the wParam
    arg of sendmessage which the gui thread uses to display messages in the
    textboxes etc. My question is that in case the threads send messages very
    fast (which does NOT always happen in my app), faster than the gui thread is
    processing them, are the messages qued automatically (btw the gui part when
    starts processing on a message, it calls entercriticalse ction and when its
    done calls leavecriticalse ction. I added these because I thought they would
    be needed, but gui thread is just one thats going to work on the message
    received and thats y I'm not sure I will need this critical section api
    calls here or not. Need some comments on this approach also.)?
    Example (writing here what I think the way things work):
    thread 1 sends message1
    thread 2 sends message2 (qued)
    thread1 send message 3 (qued)
    gui thread processes message1
    gui thread processes msg2
    thread2 sends message4
    gui thread processes message3
    gui thread processes message4

    everything done nicely, I had to do no queing my self.

    Is that what happens?

    Regards,

    Abubakar.


  • Bruno van Dooren

    #2
    Re: SendMessage API question

    [color=blue]
    > Hi,
    > in my application, different threads send notifications to GUI thread
    > through sendmessage api. They have special integer numbers inside the
    > wParam
    > arg of sendmessage which the gui thread uses to display messages in the
    > textboxes etc. My question is that in case the threads send messages very
    > fast (which does NOT always happen in my app), faster than the gui thread
    > is
    > processing them, are the messages qued automatically[/color]

    Yes. From MSDN:
    Windows 2000/XP: 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 ...
    Note that SendMEssage blocks the sender until the message is handled, and
    Post message doesn't
    [color=blue]
    > starts processing on a message, it calls entercriticalse ction and when its
    > done calls leavecriticalse ction. I added these because I thought they
    > would
    > be needed, but gui thread is just one thats going to work on the message
    > received and thats y I'm not sure I will need this critical section api[/color]

    You don't need the critical sections, as only 1 message is handled at a time
    by default.
    [color=blue]
    > calls here or not. Need some comments on this approach also.)?
    > Example (writing here what I think the way things work):
    > thread 1 sends message1
    > thread 2 sends message2 (qued)
    > thread1 send message 3 (qued)
    > gui thread processes message1
    > gui thread processes msg2
    > thread2 sends message4
    > gui thread processes message3
    > gui thread processes message4[/color]

    That is what should happen. You should keep your message handlers very small
    ..i.e. no extensive processing inside the message handlers.

    --

    Kind regards,
    Bruno.
    bruno_nos_pam_v an_dooren@hotma il.com
    Remove only "_nos_pam"


    Comment

    • Abubakar

      #3
      Re: SendMessage API question

      Thanks.

      Abubakar.

      "Bruno van Dooren" <bruno_nos_pam_ van_dooren@hotm ail.com> wrote in message
      news:#qPZ$CCSGH A.5780@TK2MSFTN GP10.phx.gbl...[color=blue]
      >[color=green]
      > > Hi,
      > > in my application, different threads send notifications to GUI thread
      > > through sendmessage api. They have special integer numbers inside the
      > > wParam
      > > arg of sendmessage which the gui thread uses to display messages in the
      > > textboxes etc. My question is that in case the threads send messages[/color][/color]
      very[color=blue][color=green]
      > > fast (which does NOT always happen in my app), faster than the gui[/color][/color]
      thread[color=blue][color=green]
      > > is
      > > processing them, are the messages qued automatically[/color]
      >
      > Yes. From MSDN:
      > Windows 2000/XP: There is a limit of 10,000 posted messages per message
      > queue. This limit should be sufficiently large. If your application[/color]
      exceeds[color=blue]
      > the limit, it should be redesigned to avoid consuming so many system
      > resources. To adjust this limit, modify the following registry key ...
      > Note that SendMEssage blocks the sender until the message is handled, and
      > Post message doesn't
      >[color=green]
      > > starts processing on a message, it calls entercriticalse ction and when[/color][/color]
      its[color=blue][color=green]
      > > done calls leavecriticalse ction. I added these because I thought they
      > > would
      > > be needed, but gui thread is just one thats going to work on the message
      > > received and thats y I'm not sure I will need this critical section api[/color]
      >
      > You don't need the critical sections, as only 1 message is handled at a[/color]
      time[color=blue]
      > by default.
      >[color=green]
      > > calls here or not. Need some comments on this approach also.)?
      > > Example (writing here what I think the way things work):
      > > thread 1 sends message1
      > > thread 2 sends message2 (qued)
      > > thread1 send message 3 (qued)
      > > gui thread processes message1
      > > gui thread processes msg2
      > > thread2 sends message4
      > > gui thread processes message3
      > > gui thread processes message4[/color]
      >
      > That is what should happen. You should keep your message handlers very[/color]
      small[color=blue]
      > .i.e. no extensive processing inside the message handlers.
      >
      > --
      >
      > Kind regards,
      > Bruno.
      > bruno_nos_pam_v an_dooren@hotma il.com
      > Remove only "_nos_pam"
      >
      >[/color]


      Comment

      Working...