My C # program running under Windows Service blocks Windows XP from hibernation

I have a windows service written in C #. It starts two threads, one combines the web service, the second waits for the Monitor object for a new job. In addition, the main thread acts as a WCF service host using NetNamedPipeBinding. It allows the client application to register a callback and then sends notifications back.

The problem is that when this Windows service is running, I cannot have a sleeping or standby computer that runs on Windows XP, SP3. When I set Windows to sleep or standby, nothing happens. Then, the moment I go to Service Manager and stop the service, the system hibernate immediately.

The extending service class ServiceBasehas properties like CanHandlePowerEvent, CanPauseAndContinue, etc. set to true ... It didn't make any difference.

The question arises: what can block the hibernation / standby mode? What should I take care to avoid this?

+3
source share
1 answer

You will only mention that you set the property CanHandlePowerEventto true. I assume that you will also have to process OnPowerEventand return trueif the status QuerySuspend, and also probably stop everything that you do, although I do not know the details of this.

More details here:

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

+5

Source: https://habr.com/ru/post/1745643/


All Articles