我一直在对我用 C# .Net 3.5 编写的 Windows 服务进行一些广泛的测试.当我重新启动或关闭计算机时,我无法让 Windows 给我足够的时间让我的服务正常关闭,即使我正在调用 RequestAdditionalTime() 方法,该方法应该更新 SCM 并保持我的服务运行.但是,如果我手动停止服务,我的代码可以正常工作.在决定在 Windows Xp 中测试代码后,我主要在 Windows Vista 和 Windows 7 中测试此代码,一切正常.有谁知道为什么这个调用在 Vista/7 中不起作用?我想我需要某种许可来防止系统关闭,这是我在 Xp 中默认获得的,但在 Vista/7 中没有.
I have been doing some extensive testing of a Windows Service I have been writing in C# .Net 3.5. I am having trouble getting Windows to give me enough time for my service to shutdown properly when I restart or shutdown the computer even though I am invoking the RequestAdditionalTime() method which should update the SCM and keep my service running. My code works properly if I manually stop the service however. I have primarily been testing this code in Windows Vista and Windows 7, upon deciding to test the code in Windows Xp everything worked perfectly. Does anyone know why this call does not work in Vista/7? I am thinking I need some kind of permission to keep the system from shutting down that I get by default in Xp but not in Vista/7.
如果系统没有关闭,你的服务可以请求额外的时间并且你的进程不会被杀死.
If the system isn't shutting down, your service can request additional time and your process will not get killed.
如果系统正在关闭,您的服务必须关闭.您甚至没有获得服务通常获得的正常 30 秒.关机比以前更有力了.
If the system is shutting down, your service has to shut down. You don't even get the normal 30 seconds that a service normally gets. Shutdown is more forceful than it used to be.
这篇关于为什么 RequestAdditionalTime() 方法在 Vista/7 中重新启动时不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!