Windows Service vs Windows Application - Best Practice
c#, windows, windows-services, winforms
Solution
My general rules of thumb are as follows
- If it needs to always run, it's a service.
- If it needs to be run under a particular user account, Network Service, Local System, generally it's a service (or a COM+ application)
- If the user needs some control over it, it's generally a notification area application.
- If it needs to notify the user of something, it's a notification area application
The fun comes when you have the need to run something as a system account, but also interact with it. IIS is a good example of this, it's a service, but the administration is an application - it needs to be running at the startup, it needs access to particular things a user can't normal access (c:\inetpub), but the user needs to be able to start, stop and configure it.
Problem
When should I go for a Windows Service and when should I go for a "Background Application" that runs in the notification area? If I'm not wrong, my design decision would be, any app that needs to be running before the user logins to the computer should be a service. For everything else use a background app. Is my decision right? Moreover, if I need "admin privileges" for my background app, I would escalate using a manifest. Are there any other specific advantage of running as a service?