Forcing windows to wait for a service to stop when it is shutting down

末鹿安然 提交于 2019-12-04 06:50:38

Windows will not let any service prevent shutdown, this is by-design. as Gyuri says, you have to consider a different design for your app.

This is a global Windows setting, apparently: http://support.microsoft.com/kb/305788. I would be worried if I had to rely on the users to let my service shut down. I would save my data periodically instead.

OnSTart and OnSTop are inherited from a base class which does quite a bit for you. All your implementations of these methods should do is start or stop your client code, windows will do the rest.

I'll caveat this with the fact that I use C# and .Net's implementation of ServiceBase does this, I cannot talk authoritatively about C/C++ code or APIs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!