Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Service Plus GUI/C#

I've seen some apps that run as a windows service but can still provide a GUI that allows the user to see what's actually going on.

For example, we've got a windows service that builds reports. There are a number of stats that admins would like to see, such as how many reports are queued up, how much ram is in use, avg build time, etc.

What we'd like to do is provide a way for the admin to see this - such as an app that can connect to the window service to gather and display this information... or maybe a way that the app itself can provide its own GUI and display it when requested. Right now, the only thing the app does it create a log file.

Is there a way to do this?

like image 885
bugfixr Avatar asked Dec 21 '09 21:12

bugfixr


People also ask

Can Windows service have GUI?

Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application.

How can a Windows service execute a GUI application?

Interacting with a User from a Service IndirectlyDesign the GUI application to communicate with the service through some method of interprocess communication (IPC), for example, named pipes. The service communicates with the GUI application to tell it when to display the GUI.

What are Windows Services in C#?

A Windows service is a long-running application that can be started automatically when your system is started. You can pause your service and resume or even restart it if need be. Once you have created a Windows service, you can install it in your system using the InstallUtil.exe command line utility.


1 Answers

Several.

  1. Have some sort of component that hooks into your windows service and sends information to another application via remoting. If you have an IoC container a clever use of decorators can do that
  2. Use a service bus, MSMQ, WCF, Growl or something like that to broadcast interesting information. Applications simply need to know how to hook in.
  3. Expose an HTTP endpoint or something where someone can connect to and download information on the windows service
  4. Or simply create a one-page WinForms app that reads the log file every so often and displays interesting results.

(Notice that last one is by far the simplest - hint hint, do that.)

like image 135
George Mauer Avatar answered Oct 26 '22 17:10

George Mauer