C# Windows Service Main Method

前端 未结 1 553
闹比i
闹比i 2021-01-04 06:08

I\'m curious how exactly the Main() method works in a windows service as it relates to the Service Control Manager. When is it executed? How does it hook into t

相关标签:
1条回答
  • 2021-01-04 06:22

    When you use the Control Panel applet to tell the service to start the SCM launches the process; this causes the code inside of Main() to run. The ServiceBase.Run() line in the Main() method hooks the associated services into the SCM who then calls the OnStart() method for each of the services specified in the ServiceBase.Run() method call.

    0 讨论(0)
提交回复
热议问题