TraceProcessor 线程安全吗?
Is TraceProcessor Thread Safe?
当我尝试通过
并行解析多个 ETL 文件时
using (ITraceProcessor processor = TraceProcessor.Create(myEtlFile, new TraceProcessorSettings
{
AllowLostEvents = true,
}))
我得到这个异常
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread.
Stack Trace:
InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, Int32 flags)
AddInManagerAdapter.Create(String toolkitPath)
ToolkitTraceProcessingEngine.Create(String path, ITraceProcessorSettings settings, ITraceProcessorSettings & effectiveSettings)
TraceProcessor.Create(String path, ITraceProcessorSettings settings)
这是错误还是 "known" 限制?
这是一个已知的限制。鉴于底层本机代码交互的工作方式,不幸的是一次只能创建一个跟踪处理器。
一般情况下,TraceProcessor只支持单线程访问,即使是静态方法也是如此。一些消费者找到了多线程代码可以工作的地方,但它不是 tested/guaranteed - 我们通常没有添加锁或做任何事情来启用安全的并发访问。
当我尝试通过
并行解析多个 ETL 文件时 using (ITraceProcessor processor = TraceProcessor.Create(myEtlFile, new TraceProcessorSettings
{
AllowLostEvents = true,
}))
我得到这个异常
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread.
Stack Trace:
InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, Int32 flags)
AddInManagerAdapter.Create(String toolkitPath)
ToolkitTraceProcessingEngine.Create(String path, ITraceProcessorSettings settings, ITraceProcessorSettings & effectiveSettings)
TraceProcessor.Create(String path, ITraceProcessorSettings settings)
这是错误还是 "known" 限制?
这是一个已知的限制。鉴于底层本机代码交互的工作方式,不幸的是一次只能创建一个跟踪处理器。
一般情况下,TraceProcessor只支持单线程访问,即使是静态方法也是如此。一些消费者找到了多线程代码可以工作的地方,但它不是 tested/guaranteed - 我们通常没有添加锁或做任何事情来启用安全的并发访问。