为什么在重新启动在Vista / 7的不是RequestAdditionalTime()方法的工作?重新启动、不是、方法、工作

2023-09-03 00:55:51 作者:专属小甜蜜丶

我一直在做一些广泛的Windows服务,我一直在写C#.NET 3.5的测试。我无法让Windows给我足够的时间,我的服务,正常关机,当我重新启动或关闭,即使我调用RequestAdditionalTime()方法,该方法应该更新SCM和保持我的业务运行的计算机。我的code正常工作,如果我不过手动停止该服务。我主要是测试这种code。在Windows Vista和Windows 7中,在判定测试code在Windows XP中一切都工作正常。没有人知道为什么这个调用不会在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.