문제

I have Windows Service written in C#. It starts two threads, one is pooling a Web Service, second is waiting on a Monitor object for a new job to arrive. Besides that, the main thread acts as a WCF service host using NetNamedPipeBinding. 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. When I set Windows to hibernate or standby, nothing happens. Then, at the moment when I go to Service Manager and stop the service, the system hibernation starts immediately.

The service class extending the ServiceBase has properties like CanHandlePowerEvent, CanPauseAndContinue, etc. set to true... That didn't make any difference.

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. 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.

More details here:

http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onpowerevent%28v=VS.80%29.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top