为什么在MFC中进行postmessage(hwnd,wparam,lparam)对话时程序挂起? [英] why did a program hang when postmessage(hwnd,wparam,lparam) to dialog in mfc?

查看:166
本文介绍了为什么在MFC中进行postmessage(hwnd,wparam,lparam)对话时程序挂起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多线程程序,当在mfc中进行postmessage(hwnd,wparam,lparam)对话时,我的程序挂起,而在保留断点时,我的程序不挂起.

i have a multithread program and when postmessage(hwnd,wparam,lparam) to dialog in mfc,my program hang and when keep a breakpoint my program don''t hang.

推荐答案

您的问题中没有足够的信息可以告诉.您将需要收集线索以尝试拉近距离并固定下来.

第一步,请尝试在调试器下运行程序,但不要设置断点(正如您所说的,当出现断点时,它不会出现问题).然后,当它挂起时,您可以从调试器窗口中断开该程序,并尝试查看它在哪里执行.这可能会给您一个提示.

您没有指出要在哪里尝试断点.您是否曾在代码中尝试过各种处理发送消息的地方?

您是否检查过用于处理UI线程中已发布消息的代码以及将消息发布到工作线程中之后的代码,以了解潜在的线程同步问题?也许是某种竞争状况?
There is not enough information in your question to tell. You will need to gather clues to try to get closer and pin it down.

As a first step, try running your program under the debugger but without breakpoints (as you say it doesn''t exhibit the problem when there is a breakpoint). Then when it hangs, you can break the program from the debugger window And try to see where it is executing. This may give you a clue.

You didn''t indicate where you where trying a breakpoint. Have you tried various places in the code that should be processing your posted message?

Have you examined the code that processes your posted message in your UI thread and the code after you post your message in your worker thread for potential thread synchronization issues? Perhaps some sort of race condition?


用您所提供的信息来回答您的查询是不可能的.

是否有要处理的消息处理程序?如果是这样,它怎么办?您是否已验证此方法不会挂起?
It''s impossible to answer your query with the information you''ve given.

Is there a handler for the message being posted? If so, what does it do? Have you verified that this method doesn''t hang?


PostMessage没有您提到的签名.


BOOL PostMessage(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);


BOOL PostMessage(UINT消息,WPARAM wParam = 0,LPARAM lParam = 0);
PostMessage does not have the signature that you have mentioned.

It is either
BOOL PostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

Or
BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);


这篇关于为什么在MFC中进行postmessage(hwnd,wparam,lparam)对话时程序挂起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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