I have a service written in C# that does not seem to come down cleanly when the computer enters sleep mode. The user needs to manually stop and restart the service to retain functionality. I know what the issue is but I am not sure where to fix it. How do Windows services behave when going into/come out of sleep and hibernate?
How do services react to power events? Really, it depends.
In your service you can handle the hibernate/suspend/etc events by handling it in your service
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
{
//do stuff here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With