C # Windows Service Basic Method

I am wondering exactly how the Main() method works in a Windows service, as it relates to the service control manager. When is it running? How does it connect to the OS? Does this happen when the service is installed? I know that it runs when OnStart () is called by SCM, OnStop () it is already running, so we won’t run it again.

If someone knows a lot about this area and can develop, I would appreciate it.

I am an experienced programmer, I do not need a description of what the Basic Method does in general ... how it works in conjunction with Windows services.

+13
c # windows-services
Dec 03 '10 at
source share
1 answer

When you use the control panel applet to tell the service to start SCM, the process starts; this causes the code to run inside Main (). The ServiceBase.Run () line in the Main () method intercepts the associated services in SCM, which then calls the OnStart () method for each of the services specified in the call to the ServiceBase.Run () method.

+13
Dec 03 '10 at 22:18
source share




All Articles