[英]My C# program running as Windows Service is blocking Windows XP from hibernation
I have Windows Service written in C#. 我有用C#编写的Windows服务。 It starts two threads, one is pooling a Web Service, second is waiting on a Monitor object for a new job to arrive. 它启动两个线程,一个是池化Web服务,第二个是在Monitor对象上等待新作业到达。 Besides that, the main thread acts as a WCF service host using NetNamedPipeBinding
. 除此之外,主线程使用NetNamedPipeBinding
充当WCF服务主机。 It lets the client application to register a callback and then sends notifications back. 它允许客户端应用程序注册回调,然后发回通知。
The problem I have is that when this Windows Service is running, I cannot hibernate or Standby my computer which is running on Windows XP, SP3. 我遇到的问题是,当这个Windows服务运行时,我无法休眠或待机在Windows XP,SP3上运行的计算机。 When I set Windows to hibernate or standby, nothing happens. 当我将Windows设置为休眠或待机状态时,没有任何反应。 Then, at the moment when I go to Service Manager and stop the service, the system hibernation starts immediately. 然后,在我转到Service Manager并停止服务的那一刻,系统休眠立即开始。
The service class extending the ServiceBase
has properties like CanHandlePowerEvent, CanPauseAndContinue, etc. set to true... That didn't make any difference. 扩展ServiceBase
的服务类具有CanHandlePowerEvent,CanPauseAndContinue等属性设置为true ...这没有任何区别。
The question is: what can be blocking the Hibernation/Standby from proceeding? 问题是:什么可以阻止休眠/待机进行? What should I take care about to avoid it? 我应该注意什么来避免它?
You only mention that you set the CanHandlePowerEvent
property to true. 您只提到将CanHandlePowerEvent
属性设置为true。 I assume that you'll also have to handle the OnPowerEvent
and return true
if the status is QuerySuspend
and also probably stop anything you're doing, though I don't know the details of this. 我假设您还必须处理OnPowerEvent
并在状态为QuerySuspend
返回true
,并且可能会阻止您正在执行的任何操作,但我不知道其中的详细信息。
More details here: 更多细节在这里:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onpowerevent%28v=VS.80%29.aspx http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onpowerevent%28v=VS.80%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.