- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正如MSDN所述:
If you are writing a single threaded application (or a multi-threaded application where only one thread accesses a DOM at one time), use the rental threaded model (Msxml2.DOMDocument.3.0 or Msxml2.DOMDocument.6.0). If you are writing an application where multiple threads access will simultaneously access a DOM, use the free threaded model (Msxml2.FreeThreadedDOMDocument.3.0 or Msxml2.FreeThreadedDOMDocument.6.0).
最佳答案
这里有多个问题。
TL; DR:
中性物体:
Is there any connection between FreeThreadedDOMDocument, neutral apartments and free-threaded marshaler?
FreeThreadedDOMDocument
的线程模型是“Both”,因此它与激活(创建)它的单元相关联。它聚合了自由线程编码(marshal)处理程序,因此它是一个自由线程对象。
FreeThreadedDOMDocument
是一个COM类,其对象聚合
free threaded marshaler。
What this marshaler does用于在处理过程中进行编码(marshal)处理时提供原始指针(即
IMarshal::MarshalInterface
设置为
dwDestContext
的
there were already free threaded objects)。
As far as I understand neutral apartment objects are supported with a free-threaded marshaler.
Does it mean that FreeThreadedDOMDocument doesn't use a free-threaded marshaler and it is called a bit confusing as free-threaded?
MSHCTX_INPROC
确实使用了自由线程编码(marshal)处理程序。
FreeThreadedDOMDocument
实例是自由线程的,因为它们聚合了自由线程的编码(marshal)处理程序,并且每个实例的生命周期都与创建它的单元绑定(bind)在一起。通常,影响不大,但带有作为STA线程的线程池,这种影响会更频繁地观察到,因为STA在拥有线程终止(正常或回收资源)并被创建时来来往往。例如,经典ASP默认情况下使用STA线程。
FreeThreadedDOMDocument
,则将隐式包含在MTA中,但它也完全不影响MTA的生存期,这意味着在使用该线程时可能会破坏MTA。它。由于几乎没有记录并且几乎不可靠,因此您不应该依赖于此。
CoInitializeEx(NULL, COINIT_MULTITHREADED)
作弊;请注意:实际上不要这样做)。实际上,如果您在STA之外或在STA之上运行的NA之外激活“Apartment”对象,则它将在主机STA中被激活。为了进一步的混淆,如果主机STA是要初始化的第一个STA,则这也可能是主STA。
What is the implementation difference between COM classes that marked as Free, Both or Neutral?
CoUninitialize
(通过
CoGetApartmentType
)的区别。
CoWaitForMultipleHandles
而不是
WaitForMultipleHandles
[
Ex
]
,这在STA中会阻塞并且是 Not Acceptable ,或者是
MsgWaitForMultipleHandles
[
Global Interface Table
Ex
,它访问窗口消息队列,可能是隐式创建,并且通常是 Not Acceptable 在MTA中。
As far as I understand they all must be thread-safe, why is the difference?
Is it correct that Neutral should support a free-threaded marshaler?
关于multithreading - FreeThreadedDOMDocument,Neutral Apartments和Free-threaded Marshaler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38505280/
正如MSDN所述: If you are writing a single threaded application (or a multi-threaded application where on
我是一名优秀的程序员,十分优秀!