How can Windows services communicate with each other?

Let's say I have two windows services running. One service - polling - polling the database for print jobs. Once a new print job is found, another service - Print - must send the job to the printer.

(Why can't I do this with one service is a separate issue, let's say there is a reason for that).

The simple idea for the solution I have is that the Poll service creates and stores the print job in some file, while the Print service tracks that location, read the file, and does the print job.

Is there a better way to do this - is it possible to somehow call the Print function directly from the Poll service?

NET 3.5 / C # development tool, if that matters.

+2


source to share


2 answers


Yes, you can use WCF so that services can talk to each other. NetNamedPipes binding is a good choice for local messages in the same mailbox.



+3


source


This is a standard IPC problem, and there are as many solutions as there are ways to strip cat: sockets, pipes, files, mapped memory, etc.



For your specific example it looks like a message queue , might be a good solution. The first service could write the job to the queue, and the second service could read it when convenient. This will work with things like printer, busy, offline, etc.

+4


source







All Articles