简体   繁体   English

.NET 中的进程间通信

[英]Interprocess communication in .NET

I have a core .NET application that needs to spawn an abitrary number of sub processes.我有一个核心 .NET 应用程序,它需要生成任意数量的子进程。 These processes need to be able to access some form of state object in the core application.这些进程需要能够访问核心应用程序中某种形式的状态对象。

What is the best technique?什么是最好的技术? I'll be moving a large amount of data between processes (Bitmaps), so it needs to be fast.我将在进程(位图)之间移动大量数据,所以它需要很快。

WCF would probably fit the bill. WCF 可能符合要求。

Here's a really good article on .NET remoting for performing distributed intensive analysis.这是一篇关于 .NET 远程处理用于执行分布式密集分析的非常好的文章 Though remoting has been replaced with the WCF, the article is relevant and shows how to make the calls asynchronously, etc.虽然远程处理已被 WCF 取代,但这篇文章是相关的,并展示了如何进行异步调用等。

This article contrasts WCF to .NET remoting -- EDIT : the key take away here shows that WCF throughput outperforms remoting for small data but approaches Remoting performance as data size increases.本文将 WCF 与 .NET 远程处理进行了对比——编辑:此处的关键内容表明,WCF 吞吐量在处理小数据时优于远程处理,但随着数据大小的增加而接近远程处理性能。

I have similar requirements and am using Windows Communication Foundation to do that right now.我有类似的要求,现在正在使用Windows Communication Foundation来做到这一点。 My data sizes are probably a bit smaller though.不过,我的数据大小可能要小一些。

For reference I'm doing about 30-60 requests of about 5K-30K per second on a quad core machine.作为参考,我在四核机器上每秒处理 30-60 个约 5K-30K 的请求。 WCF has been holding up quite well so far.到目前为止,WCF 一直表现良好。

With WCF you have the added advantages of choosing a transport protocol and security mode that is suitable for your application.使用 WCF,您可以选择适合您的应用程序的传输协议和安全模式。

我会犹豫移动大数据,我倾向于移动指向大数据的指针而不是内存映射文件。

If you truly need to have seperate processes there is always Named Pipes which would perform quite well.如果你真的需要有单独的进程,那么总是有命名管道会表现得很好。

However, would a AppDomain boundary suffice?但是,AppDomain 边界就足够了吗? Then you could do object marshaling and things would be a lot easier.然后你可以进行对象封送处理,事情会容易得多。 You application could work shared instances of the same object by using the MarshalByRefObject attribute.您的应用程序可以使用MarshalByRefObject属性来处理同一对象的共享实例。

You can use .NET remoting for inter-process communication (IPC) with IpcChannel .您可以使用 .NET 远程处理与IpcChannel进行进程间通信 (IPC)。 Otherwise you can search for shared memory wrappers and other IPC forms.否则,您可以搜索共享内存包装器和其他 IPC 形式。

EDIT: There is a MSDN article comparing WCF to a variety of methods including Remoting.编辑:有一篇MSDN 文章将 WCF 与包括远程处理在内的各种方法进行了比较。 However unless I am reading the bar graph wrong, it shows Remoting to be the same or slightly better (unlike the other comment said).但是,除非我读错了条形图,否则它会显示 Remoting 相同或稍好(与其他评论不同)。 There is also ablog post about WCF vs. Remoting.还有一篇关于 WCF 与 Remoting 的博文 The blog post clearly shows Remoting is faster for binary objects and if you are passing Bitmaps (binary objects) then it seems Remoting or shared memory or other IPC option might be faster, although WCF might not be a bad choice anyway.博客文章清楚地表明,对于二进制对象,远程处理速度更快,如果您正在传递位图(二进制对象),那么似乎远程处理或共享内存或其他 IPC 选项可能更快,尽管无论如何 WCF 可能不是一个糟糕的选择。

I have a core .NET application that needs to spawn an abitrary number of sub processes.我有一个核心.NET应用程序,需要产生大量子进程。 These processes need to be able to access some form of state object in the core application.这些过程需要能够访问核心应用程序中的某种形式的状态对象。

What is the best technique?最好的技术是什么? I'll be moving a large amount of data between processes (Bitmaps), so it needs to be fast.我将在进程(位图)之间移动大量数据,因此它需要快速。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM