How to make a windows service that has a task tray icon for managing it? RRS feed

  • Question

  • Hi folks,

    I'm familiar with writing windows service applications. I've written a few using various approaches - third party libs, the .NET-provided approach, etc. None of my prior applications had any way to interact with them, though.

    I'm needing now to write a windows service application, but it will need a task tray icon that perhaps brings up a "management GUI" when you click on it.

    What is the appropriate pattern for doing this?

    Should the service be its own application, but is able to be interacted with through external means - perhaps a database that it polls for config changes? Should it use IPC or something?

    Is there a way to make a windows service also have a GUI so that the management GUI and the service are all just the same application?

    I really don't know, and am doing initial research to determine the best route to go with this.


    Tuesday, February 5, 2019 5:14 PM

All replies

  • A Windows service can have a GUI.

    It depends on how you want your service to run. For example, if you need the service to continue running while the user is logged out then you can't have any kind of GUI. This is usually the case.

    A typical pattern is to have two apps. The first is the service and the second is the dashboard. The dashboard is a forms app that allows the service admin to make changes as needed. The service can either be restarted or have it poll as you mentioned. Since restarting the service can be done from the dashboard, this is preferable, unless you absolutely need the service to be always up. If this is the case then polling is the sane way to do it. Saga

    You can't take the sky from me

    Tuesday, February 5, 2019 7:03 PM
  •  If this is the case then polling is the sane way to do it.

    There is a simple way for avoiding the polling. From the desktop app, after making the changes, you use the ServiceController class to send a command to the service. In the service, you override the OnCommand method. This will be triggered upon receiving the command from the app, and in this way the service knows that it has to re-read its configuration, without needing any polling.
    Tuesday, February 5, 2019 8:07 PM
  • That's awesome! And the service does not have to restart! Thanks for that. Saga

    You can't take the sky from me

    Tuesday, February 5, 2019 8:22 PM
  • Hi ryanils,

    Thank you for posting here.

    For your question, you could download the source file from the code project for reference.

    A Task Tray Applet Framework:

    Tray Me:

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Proposed as answer by Stanly Fan Tuesday, February 12, 2019 6:25 AM
    Wednesday, February 6, 2019 2:36 AM