winapi - MTA COM 服务器的实现

标签 winapi com mta

我找不到任何有关 MTA 兼容 COM 的先决条件的源代码。我尝试将对象的 ThreadingModel 注册表项从 Apartment 更改为 Both,当辅助线程在访问任何数据之前调用该方法时,会导致崩溃。

如果 STA COM 需要消息泵,那么 MTA COM 对象需要什么样的管道代码?

最佳答案

我不认为 MTA 有什么特别之处,只是您需要使用互斥体等同步原语来同步对内部结构的访问。 "Multithreaded Apartments" 是否没有给你你需要的一切?

引用文档,重点是我的:

Because calls to objects are not serialized in any way, multithreaded object concurrency offers the highest performance and takes the best advantage of multiprocessor hardware for cross-thread, cross-process, and cross-machine calling. This means, however, that the code for objects must provide synchronization in their interface implementations, typically through the use of synchronization primitives such as event objects, critical sections, mutexes, or semaphores, which are described later in this section. In addition, because the object doesn't control the lifetime of the threads that are accessing it, no thread-specific state may be stored in the object (in thread local storage).

关于winapi - MTA COM 服务器的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22912271/

相关文章:

c++ - 终止已由另一个服务启动的服务(内核级)

c++ - "pure"IDispatch 接口(interface)是否需要代理/ stub DLL?

delphi - 替换Delphi XE3中的RIDL文件和typelib

multithreading - 关于COM多线程和STA/MTA的问题

linux - 如何在 Linux 中配置仅发送邮件服务器,该服务器将为同一网络中的多个应用程序/Web 服务器接受并执行电子邮件传递

.net - ASPX 页面中的 Aspcompat

emacs - windows GNU emacs 中的 .emacs 文件在哪里

multithreading - 如何在不输入的情况下测试临界区是否被锁定?或者,如何等到 critsec 被另一个线程拥有?

com - C# COM DLL : do I use Regasm, 或 Regsvr32?

c++ - 在没有它们的笔记本电脑上创建 Alt 代码