简体   繁体   中英

wcf implementation for interprocess communication

I have developed a .NET UI and windows service which communicate with each other using WCF through the NetNamedPipeBinding protocol. I chose NetNamedPipe because it is the best and efficient choice for interprocess communication on the same machine.

However, one of the key requirements of the application is that the UI should be able to send actions to the windows service and vice versa asynchronously. This means that the windows service should be able to call back the .NET UI application without the need for the .NET UI application to connect to the windows service first.

Keeping this in mind, I have hosted a WCF service in the windows service and a separate WCF service in the .NET UI application so that they can communicate asynchronously without the need to keep the communication channel always alive.

I would like to know if this makes good design sense.

I would appreciate your comments on the same.

Thanks in advance.

Subbu

Hosting another WCF service in the client to receive calls from the main WCF service is not a good idea. You need to use WCF duplex communication (as Subbu posted) aka WCF callback.

WCF: Duplex Operations and UI Threads

The problem with this approach is that your service needs to connect to the client as a host.

A better option would probably be to setup a WCF Callback when you first startup the client. The service can then use the callback for service to client notifications. For details, see this MSDN article which shows using WCF callbacks.

WCF Callback allows server to drive events to the client. See a short and simple example here: A simple WCF Callback example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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