Web 浏览器控件/单线程单元帮助 - .NET
我知道 IE WebBrowser 控件是一个 COM 对象,它在单线程单元中运行,因此不能轻松线程化。我的问题是,如果两个完全独立的应用程序调用此 COM 控件,每个应用程序是否都有自己的线程,或者是否在核心 IE 引擎的幕后同一线程上处理这两个应用程序?
一个例子是我有 Test.EXE,它除了处理一个非常大的网站之外什么也不做(我们假设单个线程需要 3 分钟来处理)。如果我打开这个 30 次,所有 3 个实例是否仍在单个线程中工作,因此并没有真正加快处理 30 个实例所需的时间,或者每个实例都会获得自己的线程/ IE 实例,并且理论上会处理所有 30 个实例大约在同一时间它处理一个?
我尝试对此进行测试,添加的线程越多,每个线程似乎运行得越慢(甚至在我的处理器接近最大化之前。我的内存甚至不是一小部分)。
I understand IE WebBrowser control is a COM object that runs in a single thread apartment and thus cannot be easily threaded. My question is if two completely separate applications make a call to this COM control, does each get its own thread or does it handle both on the same thread behind the scenes in the core IE engine?
An example would be I have Test.EXE that does nothing more than process an extremely large website (let’s assume it takes a single thread 3 minutes to process). If I open this 30 times, would all 3 instances be still working in a single thread, thus not really speeding up the time it takes to process 30, or would each get its own thread / instance of IE and in theory process all 30 in about the same time it processes a single one?
I tried testing this and the more threads I add, the slower each seems to go (Even before my processor comes near maxed. My ram is not even a fraction).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个应用程序都在自己的进程中运行,因此将拥有自己的 WebBrowser 控件副本。他们不能互相干扰。
Each application runs in its own process, so will have its own copy of the WebBrowser control. They cannot interfere with each other.
WebBrowser 控件是 IE 进程内 COM 服务器的包装器。这意味着它将被加载到使用它的每个进程中。每个进程都能够使用其主线程与其进行通信。
The WebBrowser control is a wrapper around the IE in-process COM server. This means that it will be loaded into each process which uses it. Each process will be able to communicate with it using its main thread.