如何通过托管进程服务非托管线程 [英] How to serve unmanaged threads via a managed process

查看:146
本文介绍了如何通过托管进程服务非托管线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图设计类似ASP.NET的东西,但需要进一步了解如何进行编程/设计.

将有很多非托管线程需要由托管进程(DLL)提供服务.我知道只有一种方法可以做到:

Trying to design something like ASP.NET, but need further understanding as to how to go about programming/designing it.

There would be a lot of unmanaged threads which needs to be served by a managed process (DLL). I know just one way to do this:


  1. 从非托管线程(使用COM接口)托管CLR
  2. 创建AppDomain并加载所需的程序集
  3. 调用托管程序集中的方法进行服务(此方法将更新包含将需要由非托管线程进行进一步处理的数据的数据结构)
  4. 卸载appdomain和clr

  1. host the CLR from the unmanaged thread (using COM interfaces)
  2. Create the AppDomain and load the required assembly
  3. Call the method in the managed assembly to do the serving (this method updates a data structure which contains data will need to get further processed by the unmanaged thread)
  4. unload the appdomain and clr


但是推荐这种方式吗?因为每次您创建CLR并将其销毁.我感觉那里一定有表现受到打击.


But is this way recommended? Because each time you are creating the CLR and destroying it. I sense there must be a performance hit there. Can we obviate this?

推荐答案

deostroll写道:
deostroll wrote:

我们可以解决这个问题吗?

Can we obviate this?



使用C ++/CLI作为未管理代码到托管代码之间的接口.然后,无需创建CLR和AppDomain.



Use C++/CLI for the interface between unmanged-to-managed code. Then no need to create the CLR and AppDomain.


这篇关于如何通过托管进程服务非托管线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆