views:

41

answers:

2

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 information 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.

+1  A: 

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:

marc_s
Beat me by a few seconds. Also, if all communication is local to the machine, you can used named pipes (`net.pipe`) for very fast communication.
josh3736
Josh, make your comment an answer because so far, you've got my vote
Max Yaffe
A: 

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.

Eugene Mayevski 'EldoS Corp
Nothing wrong with a 3rd-party solution. However, given that he's moving to .NET, WCF is my recommendation since it's included in the .NET Framework.
Matt Davis