CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,895

    message processing question

    I just want to know if the following scenario is normal

    all in same thread

    I post a message using PostMessage (M1) and carry on, few ms later I post another message (M2)

    M1 is picked up and started to process

    Here is my question, while processing M1 (which calls a web service), is it possible for M2 to be started processing before the method that process M1 finishes?

    ie. is the thread blocked while M1 is processed fully or can another message M2 be picked up and start to be processed?

    thanks in advance.
    and Canada rocks!! Peace bro.

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: message processing question

    ie. is the thread blocked while M1 is processed fully or can another message M2 be picked up and start to be processed?
    A thread can only do 1 thing at the same time, so yes it is blocked.

  3. #3
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: message processing question

    Quote Originally Posted by IndikaNiva View Post
    ...M1 is picked up and started to process...
    If you start processing on the same thread - then yes, it will be blocked. But you can create a separate thread for your long processing, that's what threads are for
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  4. #4
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,895

    Re: message processing question

    Thanks for the reply, This is what I thought too...
    but the behavior I am seeing is different.
    M1 method calls a web service via wcf, which takes about half a second to reply, during this time, M2 is starting to get processed.

    can the thread be going into idle state while waiting for the web server responds, thus giving time to start processing M2?
    and Canada rocks!! Peace bro.

  5. #5
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: message processing question

    Quote Originally Posted by IndikaNiva View Post
    M1 method calls a web service via wcf...
    Is that a synchronous call?
    Also, wcf? Should you move it to another forum?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  6. #6
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,895

    Re: message processing question

    I am in a C++ dll, which calls a C# COM Callable dll to talk to a server
    in M1 I call a method from this C# com callable dll, while waiting for this method to return, my C++ code starts processing M2.

    What is going on?? thanks for all your help.
    and Canada rocks!! Peace bro.

  7. #7
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: message processing question

    Quote Originally Posted by IndikaNiva View Post
    I am in a C++ dll, which calls a C# COM Callable dll to talk to a server
    in M1 I call a method from this C# com callable dll, while waiting for this method to return, my C++ code starts processing M2.
    Again, is that a synchronous call?
    Are you sure that you are “waiting for this method to return”?
    Let me re-state: if you are in your WindowProc, processing a message, the next message will NOT be processed until you return from that WindowProc. Unless, of course, there is a PeekMessage call somewhere.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  8. #8
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,895

    Re: message processing question

    Thanks VladimirF, this is what I am thinking also somewhere in our C++ code we must be calling peek and DispatchMessage.

    BTW, long time no see. thanks again.
    and Canada rocks!! Peace bro.

  9. #9
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: message processing question

    Quote Originally Posted by IndikaNiva View Post
    ...somewhere in our C++ code we must be calling peek and DispatchMessage.

    BTW, long time no see. thanks again.
    You might be looking in the wrong places.
    I think your PeekMessage() should in the SAME thread, so for it to work it MUST be in your C# COM dll.
    You are welcome!
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured