线程安全和 AfxMessageBox

发布于 2025-01-05 20:42:42 字数 221 浏览 5 评论 0原文

AfxMessageBox函数线程安全吗?

我看到 AfxMessageBox 调用 AfxGetMainWnd()->GetSafeHwnd() 和 CCmdTarget::GetRoundingFrame_()->GetSafeHwnd() 等背后的 MFC 代码,我想知道它的线程安全性。

如果我有多个 GUI 线程,是否可以从其中任何一个线程调用 AfxMessageBox?

Is the AfxMessageBox function thread safe?

I see the MFC code behind AfxMessageBox invoking such as AfxGetMainWnd()->GetSafeHwnd() and CCmdTarget::GetRoundingFrame_()->GetSafeHwnd(), and I'm wondering about its thread safety.

If I have multiple GUI threads, is it OK to invoke AfxMessageBox from either of them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山色无中 2025-01-12 20:42:42

是的,它是线程安全的。来自 MSDN

如果从应用程序的主线程调用 AfxGetMainWnd,它将根据上述规则返回应用程序的主窗口。如果从应用程序中的辅助线程调用该函数,该函数将返回与发出调用的线程关联的主窗口。

Yes it is thread-safe. From MSDN:

If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文