当存在多个 .net 进程实例时如何与它们通信
我在同一台计算机上运行同一 Windows Forms .net 3.5 SP1 C# 应用程序的多个实例。
现在我希望能够通过 .net 与他们进行通信,一次一个实例。 最简单的方法是什么?
我读了一些有关 WCF 的内容,但我只找到了使用一台服务器和一个客户端的示例。但就我而言,所有正在运行的实例都是一台服务器,我只需要与其中一个实例进行讨论。
我想象这样的事情:
Process[] procs = Process.GetProcessesByName("ProcessName");
foreach (Process p in procs)
{
// Communicate with process here
}
I have multiple instances of the same Windows Forms .net 3.5 SP1 C# application running on the same machine.
Now I'd like to be able to communicate with them from .net, one instance at a time.
What's the most simplest way to do this?
I read a bit about WCF, but I have only found examples working with one server and one client. But in my case all running instances would be a server and I need to discuss with just one of them.
I imagine something like this:
Process[] procs = Process.GetProcessesByName("ProcessName");
foreach (Process p in procs)
{
// Communicate with process here
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要某种订阅/回调机制。不要循环遍历项目,而是让每个应用程序订阅一个 wcf 服务方法。
示例: http://idunno.org/存档/2008/05/29/wcf-callbacks-a-beginners-guide.aspx
You'll need some kind of subscribe/callback mechanism. Don't loop through the projects, but have each application subscribe to a wcf service method instead.
Example: http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx
简单的是数据库:),顺便说一句,WCF 支持与 NetPeerTcpBinding 的点对点通信
The simple thing is database :) , btw WCF support peer to peer communication with NetPeerTcpBinding