Why doesn#39;t the RequestAdditionalTime() method work on restart in Vista/7?(为什么 RequestAdditionalTime() 方法在 Vista/7 中重新启动时不起作用?)
问题描述
我一直在对我用 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 中重新启动时不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 RequestAdditionalTime() 方法在 Vista/7 中重新启动时不起作用?
基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01