gpt4 book ai didi

windows -::PostMessage 到一个无效的 hWnd

转载 作者:可可西里 更新时间:2023-11-01 11:19:53 25 4
gpt4 key购买 nike

我有一个线程调用 ::PostMessage(hWnd, [...]); 向主线程发送一条消息,提醒它注意异步操作的结果。

但是,我担心如果线程需要特别长的时间来完成它的操作,当调用 PostMessagehWnd 可能不存在(用户可能已经关闭了窗口)。

MSDN Documentation如果 hWnd 无效,则不会说明任何结果。

如果 hWnd 无效,您是否从经验或其他文档中知道我会发生什么?

最佳答案

Raymond Chen 写道:

一些选择摘录:

It so happens that boatloads of programs (and "boatloads" is a technical term) contain bugs where they use window handles after the window has been destroyed. When a window handle is re-used, that program sends a message to the window it thinks is still there, but instead it sends the message to a completely unrelated window. This doesn't bode well for the program, and it usually doesn't bode well for the new window that received the message by mistake either.


We left off our story last time by raising the problem of programs that send messages to windows that have already been destroyed and how window handle re-use exacerbates the problem. Although this is clearly a bug in the programs that use window handles after destroying the window, the problem is so widespread that the window manager folks in Windows NT decided to take a more proactive approach.

关于windows -::PostMessage 到一个无效的 hWnd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17096073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com