1

I have been quite comfortable with windows-services, I have been practicing since from last two weeks. Would you please explain me some of the basic applications of Windows service, so that I can take it as homework and practice. (it need not be too basic)

I have already designed and implemented a project/service which is meant for closing all the browsers, when I open a program(or process) saying "Gtalk".

I am interested and very eager to learn more things about Windows services.

Regards.

Rookie Programmer Aravind
  • 11,952
  • 23
  • 81
  • 114
  • 1
    On my project, we use a Windows service to do things that require elevated system privileges on behalf of the user that may be logged in with no administrative rights at all. For example, you have to be a local admin to open a "raw" socket. Our Windows service does this and sends the collected network data to the front-end application for user processing. We are using .NET, so we leverage WCF to communicate between the service and the app. – Matt Davis Mar 18 '10 at 14:25

3 Answers3

3

The word 'service' (Windows or othwerwise) implies that it is something that runs without a User Interface and possibly without any user interaction; it is constantly 'running' waiting to service commands sent to it.

a Windows service is a long-running executable that performs specific functions and which is designed not to require user intervention. Windows services can be configured to start when the operating system is booted and run in the background as long as Windows is running, or they can be started manually when required.

Ref.

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
  • thanx for the response, Well. The basic Idea I got is from wiki. I just wanted some homework projects to practice with. – Rookie Programmer Aravind Mar 18 '10 at 07:38
  • 1
    Well, it a bit hard to answer unless you have something specific in mind. How about creating a service that submits a search to several different search engines and collates the results? Or create a service that monitors other services? The list is endless... – Mitch Wheat Mar 18 '10 at 07:52
1

You could try implementing your own scheduler? I think the most basic use of services is to have automatic process run according to a particular schedule.

Phil Gan
  • 2,813
  • 2
  • 29
  • 38
1

Few points

  1. The OnStart method should return within 30 seconds or the SCM will time out. OnStart should handle all initialization of your service. The constructor is called when the application's executable runs, not when the service runs. The executable runs before OnStart. When you continue, for example, the constructor is not called again because the SCM already holds the object in memory.

  2. ServiceAccount: Some of the bugs in windows service are caused by inability to access privileged resources. Choose account type carefully or have a custom account.

  3. Asynchronous Programming: In case you are going to connect to web services, then asynchronous programming approach is far better approach.

  4. System.Timers.Timer: In case your service does "something" periodically, consider using System.Timers.Timer.

What can Services do under Windows?

Testing windows service

Community
  • 1
  • 1
PRR
  • 1,190
  • 7
  • 13