I have a .Net console App which using a scheduled event will start, call a mweb service method and the close. This runs every hour/every day. Whilst there is nothing 'wrong' with the implementation I was wondering if there was any benefit to implementing this as a windows service.
Has anyone any views of what would be the best practice in this case?
The key difference between a process running as an app versus as a service is that the service can operate entirely outside the normal association with a user and session. Thus services can run such that they start before any user logs in and can continue running after users log off.
A console application is primarily designed for the following reasons: To provide a simple user interface for applications requiring little or no user interaction, such as samples for learning C# language features and command-line utility programs.
The sole difference is that a console application always spawns a console if it isn't started from one (or the console is actively suppressed on startup). A windows application, on the other hand, does not spawn a console. It can still attach to an existant console or create a new one using AllocConsole .
Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.
I Find Windows services hard to debug so I tend to only use them when:
(A) What I am doing is quite complex or
(B) needs to be running all the time(Example: Monitoring something for changes)
I find most things can usually be accomplished with a Console App some command line args and the Windows Scheduler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With