SendMessage对PostMessage + WaitForSingleObject [英] SendMessage vs PostMessage + WaitForSingleObject

查看:280
本文介绍了SendMessage对PostMessage + WaitForSingleObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道调用SendMessage(哪些块)和调用PostMessage结合WaitForSingleObject有什么区别。
想法?

I was wondering what's the difference between calling SendMessage (which blocks) and calling PostMessage in conjunction with WaitForSingleObject. Thoughts?

推荐答案

SendMessage() ,如果从COM调用的上下文中调用它,其中COM对象居住在STA中(通过消息泵分派调用)。 PostMessage()不限于遵守COM公寓规则。

SendMessage() may be denied, if you call it from within the context of a COM call, where the COM object lives in an STA (calls are dispatched through the message pump). PostMessage() is not restricted to adhere to COM apartment rules.

此外, PostMessage ()将消息放在窗口的消息队列的末尾。 SendMessage()绕过队列。您可以在Raymond Chen的博客旧新事物上查看有关消息队列的更长时间的讨论。

Also, PostMessage() puts the message on the end of the window's message queue. SendMessage() bypasses the queue. You can find a lengthier discussion on message queues on Raymond Chen's blog The Old New Thing.

我的观点是 SendMessage() PostMessage()满足眼睛。我真的建议通过Raymond的博客,因为他已经涵盖了许多问题多年。

My point is that there is more to the difference between SendMessage() and PostMessage() than meets the eye. I really recommend going through Raymond's blog, as he has covered many gotchas over the years.

这篇关于SendMessage对PostMessage + WaitForSingleObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆