Inter-Process communication options

2019-02-22 02:38发布

问题:

I need to subscribe inside one app for the event exposed by another app. I noticed that many people consider the using of WCF Named Pipes as the best practice. Am I right that if I choose WCF Named Pipes I'll have to use IIS?

And by the way, what options do I have in general?

回答1:

Named pipes are one of the fastest way to do IPC (inter-process communication) on the same machine. The have existed for a long while (was NT4 the first OS?) and not specific for WCF.

I would however not use WCF/Named pipes through ASP.NET as IIS do not use named pipes for it's communication. that means that your app will close if IIS have not received HTTP requests for a while.

How you should host your IPC depends on the type of application. If you want to always have your server running you should host it in a windows service. Otherwise you could just include it in your desktop app.

You do not necessarily have to use WCF, you can use named pipes directly (look at the link in the beginning of my message). It all depends on how complex your communication is.



回答2:

Am I right that if I choose WCF Named Pipes I'll have to use IIS And by the way, what options do I have in general?

No, not really. Although this is an option but you have other options as well. Like,

  • Self-Hosting Your Service
  • Hosting in Windows Services
  • Hosting Using Internet Information Services (IIS)

    which you can read in detail here.

Named pipes existed even before WCF and WCF is certainly not the only way to use them