简体   繁体   中英

Communication between WCF and hosting Windows Service

This question is a Follow up to This

In the project I am currently working on, I have a windows service which is actually a TCP/IP server which is connected to some set of hardware.. The windows service collects data from the hardware and stores into a database and may also send some configuration commands to the hardware.. There is an asp.net website through which the user may ask the windows service for some data or even send some configuration commands for hardware through windows service..

As of now I am considering to host WCF inside the windows service and make asp.net to consume this service.. So, I want the WCF to invoke some of the procedures in my windows service when the user requests through the website.. is it possible? if it is please explain..I have searched a lot for this type of communication but all in vain.. if it is not possible suggest me some alternative approach to WCF... Please help, will be grateful.

If you make your WCF service a singleton you can create an instance to it and pass that to the ServiceHost. You can pass constructor an interface implemented in the windows service which the WCF service can use to talk to the Windows service - this interface implementation can act as a broker for the communication between the WCF service and the windows service

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