Reputation: 4929
Are there situations that we should use a windows service ?
I am building a client-server project (c#) and the server supposed to work alone without any user so someone advised me to use a windows service to run the server, is this right ? or there are a better solutions ?
Upvotes: 7
Views: 10403
Reputation: 53699
When you need the application to start running even when no one has physically logged into the machine, which is common with server machines, a service is a good candidate in this case. Especially because the service can be configured to auto start, which means the service will start when the machine is rebooted withut human intervention.
If however you are wanting to host web services (WCF) while a service is an option, you might consider hosting in IIS, this relieves you of writing the actual hosting code etc.
Upvotes: 1
Reputation: 31848
In your situation I would use a service for the following reasons:
Upvotes: 8
Reputation: 150108
Windows services are the right thing to use for something that should run all of the time, whether or not a user is logged in.
If you need something to run without an active user logged in, you need to use a windows service.
Upvotes: 1
Reputation: 1312
Well, a Windows Service provides a full framework for your application to work and to remain active while you want it to, so I think its ok.
Upvotes: 1
Reputation: 10857
Windows service can start running as soon as the machine is powered up, which makes ideal for running as a server, http server for example. No one is required to login.
Upvotes: 6
Reputation: 115488
Windows services are normally used when an application needs to continuously run. For example if they need to:
If a program just needs to run periodically, like once a day. It is normally easier to create a scheduled task.
Upvotes: 8
Reputation: 887451
You should create a Windows Service to run code in the background, without user interaction.
For example, a Windows Service will run even if no-one is logged on.
Any server that accepts connections (such as a mail, web, or FTP server) should usually be a Windows Service.
Upvotes: 1