What is the simplest method of inter-process communication between 2 C# processes?

后端 未结 7 1687
甜味超标
甜味超标 2020-11-22 07:31

I want to create a communication between a parent and a child process, both written in C#.

It should be asynchronous, event-driven.

I don\'t want to run a thre

7条回答
  •  长情又很酷
    2020-11-22 08:14

    The easiest solution in C# for inter-process communication when security is not a concern and given your constraints (two C# processes on the same machine) is the Remoting API. Now Remoting is a legacy technology (not the same as deprecated) and not encouraged for use in new projects, but it does work well and does not require a lot of pomp and circumstance to get working.

    There is an excellent article on MSDN for using the class IpcChannel from the Remoting framework (credit to Greg Beech for the find here) for setting up a simple remoting server and client.

    I Would suggest trying this approach first, and then try to port your code to WCF (Windows Communication Framework). Which has several advantages (better security, cross-platform), but is necessarily more complex. Luckily MSDN has a very good article for porting code from Remoting to WCF.

    If you want to dive in right away with WCF there is a great tutorial here.

提交回复
热议问题