MFC 与 COINIT_MULTITHREADED 冲突
来源:互联网 发布:电脑作图软件 编辑:程序博客网 时间:2024/05/22 05:02
SYMPTOMS
When you use the following CoInitializeEx method call to initialize a Microsoft Foundation Class Library (MFC) application as a multithreaded apartment (MTA), the application may stop responding:
CoInitializeEx(NULL, COINIT_MULTITHREADED)
CAUSE
An MFC application uses a lot of thread local storage to store thread state information and to process state information. Therefore, an MFC application is not compatible with a free threaded programming model. For example, if you write an application that displays a user interface (UI) and that also uses some remote Component Object Model (COM) objects, during any method calls to the remote COM objects, the UI may stop responding. This behavior occurs because the UI thread that you initialize as an MTA thread by using the CoInitializeEx(..., COINIT_MULTITHREADED) method makes blocking Remote Procedure Calls (RPCs) to another COM apartment. While the UI thread waits for the RPC response message, any window messages that are posted to the queue of the UI thread are accumulated. Therefore, windows that were created by the UI thread may stop responding. This behavior may cause end users to prematurely quit the application.
RESOLUTION
To work around this problem, run the MFC application (UI thread) in a Single Threaded Apartment (STA). To do this, initialize the MFC application by using the CoIntializeEx(..., COINIT_APARTMENTTHREADED) method. When an STA thread makes an RPC call, the thread drops into a COM-managed message loop (to dispatch window messages), and COM creates another thread to receive the RPC response message. Because the COM-managed message loop supports the dispatch of window messages, the UI can keep running.
- MFC 与 COINIT_MULTITHREADED 冲突
- MFC与valarray的冲突
- PCL与MFC 冲突总结
- 关于Caffe应用与MFC冲突问题
- 解决扩展MFC DLL与主程序资源冲突问题
- MFC的DEBUG_NEW与GDI+的冲突问题
- std::min,std::max 与 MFC冲突的解决
- IE8与vs2005冲突 MFC类向导错误解决方法
- MFC的DEBUG_NEW与GDI+的冲突问题
- dll导出函数 与mfc 函数冲突问题
- std::min&std::max与mfc冲突问题
- MFC资源冲突解决方法
- vs.net2005与ie7冲突(不能通过向导创建基于MFC的移动设备工程)
- IE8与vs2005冲突 添加MFC类向导错误解决方法—— internet explorer脚本错误
- Ogre1.6和MFC内存泄露冲突
- MFC防止资源冲突的简单方法
- PowerDesigner与Word冲突
- 暴力冲突与和气生财
- .NET泛型基础
- 老实人在华为3Com,有点意思(转)
- 青花瓷
- OOM和JVM配置优化(一)
- OOM和JVM配置优化(二)
- MFC 与 COINIT_MULTITHREADED 冲突
- 定制基于注册表的组策略
- 动态生成的Web软件 应该如何设计???
- 中国oracle ace名单(都是牛人)
- 贴片元件的焊接
- CDN工作原理
- C#面向对象设计模式纵横谈 学习笔记11 Facade外观(结构型模式)
- PHP程序加速探索之服务器负载测试
- 辞职了