1

I have a Windows Service, and I want it to be able to communicate with my desktop app. The desktop app is a WinForms app. The service should be able to communicate with the app in the background, and while the app is running. Launching the app with commands from the service is not acceptable.

How can a Windows Service (or another WinForms app) communicate with another WinForms desktop app while the app is already running?

NDEIGU
  • 2,563
  • 2
  • 12
  • 13

1 Answers1

2

Unfortunately I don't have a simple answer.

There are several choices for IPC(Inter Process Communication) such as: Mailslot, NamedPipe, Memory Mapped File, Socket, Windows Messaging, Remoting, WCF, Web sockets with a local web server, watching a shared file, message bus, ...

See more at:
Passing Information Between Applications in C#
Communication between ASP MVC and WinForm Applications

HTH

Community
  • 1
  • 1
LosManos
  • 7,195
  • 6
  • 56
  • 107
  • Thanks @Los, Looks like I'll be going the Shared File route. Not much time to read up on the others and shared file seems to be the most flexible for what I have in mind. – NDEIGU May 19 '15 at 15:39
  • 1
    @SE505 `NamedPipe` is not too hard. Shared file is simple, but not good for concurrent calls. You should consider spending a bit of time looking at `NamedPipe`. – Loathing May 19 '15 at 18:27
  • 1
    @SE505 Here is some example code on System.IO.FileSystemWatcher http://stackoverflow.com/a/721743/521554 Note though that Notepad touches a file twice. I have wasted hours when developing a solution due to this behaviour. Twice. – LosManos May 20 '15 at 06:26