开发者

Communicating with a Windows Service

I'm looking for the best way to use a Windows Service to manage a group of objects for use by several different client programs. The service must

  1. create the list of objects corresponding to physical or virtual devices,
  2. maintain information about what process is currently using a given device and what devices are available to be used,
  3. manage requests to use a given device by a process,
  4. return devices to an unused state.

When I look at the Windows Service examples, though, there is very limited communications to Services. OnCustomCommand doesn't return any info开发者_如何学运维rmation to the caller.

So is there a recommended way to establish information exchange between a service and various clients?

For background - I am replacing a Win32/COM app with a .Net app. The current device manager is a COM server with the clients being COM clients.


You could always implement a WCF service inside your Windows Service to communicate with the outside world. It would do so using either HTTP or Net/TCP (in a corporate LAN environment) or other transports (like MSMQ message queueing, if appropriate).

When the Windows Service spins up, you could also bring up a WCF ServiceHost to handle those communication needs.

See:

  • MSDN: How to host a WCF service in managed Windows Service
  • Self-hosting WCF services
  • WCF Essentials - hosting the service


Just an option - MsgConnect library for transparent communications between applications on the same or different systems. Designed specifically with your task (service-GUI communication) in mind. With MsgConnect you can send and receive messages (much like you do in Windows) which carry custom data. On local system messages can be transferred using MMF or sockets, for remote communications TCP sockets or HTTP can be used.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜