What is the difference between Send Message and Post Message and how these relate to C# ,WPF and Pure windows programming?

后端 未结 1 979
不思量自难忘°
不思量自难忘° 2020-12-04 17:20

What is the difference between Send Message and Post Message ( in terms of pure windows programming) and how these relate to C# ,WPF and Pure windows programming?

I

相关标签:
1条回答
  • 2020-12-04 18:02

    PostMessage (in "pure windows programming", aka win32 API) is asynchronous, i.e., to quote the docs:

    Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

    To post a message in the message queue associated with a thread, use the PostThreadMessage function.

    SendMessage is synchronous, that is, again quoting:

    Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

    To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.

    A good tutorial on these two functions and their use is here.

    The connection to WPF is discussed in this SO question.

    0 讨论(0)
提交回复
热议问题