Kyle G. Kyle G. - 9 months ago 57
C# Question

Communication between Windows Service and Desktop Application

I know that similar questions have been asked before, but even after all my Googling I'm still completely lost.

I've written a small Windows Service that does what my main application used to do in a background thread (it made sense to move it to a separate service for several reasons).

When the background thread was running as a part of my application it would fire an event every time it finished working (updating a database, in this case) and I would use a timestamp from that event to grab the appropriate information to update the window. I don't think the specifics are relevant, but please let me know if you need more details.

Now that I've got the database-filling stuff running as a service, the question becomes: How do I replace what used to be done by the event?

In other words, what's the simplest and/or most effective way to communicate a basic DateTime from my service to my app?

I've never done any IPC before but started reading up on it and got thoroughly confused.

Named Pipes
seem to be my best bet so far, but I've been unable to find anything that helps me understand their functionality... All I've found are poorly-commented chunks of code or "tutorials" that go way deeper than I need, without clearly covering the basics.

So, without being able to establish a good base, I'm a little stuck. What's the best method to implement simple communication that does what my event used to do and where can I learn the basics of that method?


As always, everyone here rocks, thanks for all the quick responses. Gerrie's link turned out to be exactly what I needed (though I didn't know that's what I needed at the time).

Answer Source

Don't get scared away by the named pipes concept, WCF will take care of the nasty bits for you. You'll only have to do the configuration, it's simply another communication channel, instead of using HTTP for example. So you'll need to look into WCF.

Check out this tutorial.