如何Windows服务的行为进入/从睡眠状态唤醒或休眠模式? [英] How do Windows services behave when entering/waking up from sleep or hibernate modes?

查看:835
本文介绍了如何Windows服务的行为进入/从睡眠状态唤醒或休眠模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#编写似乎不下来干净,当计算机进入睡眠模式的服务。用户需要手动停止和重新启动该服务以保留功能。我知道是什么问题,但我不知道在哪里可以修复它。如何Windows服务的行为时去到/来睡眠出来和休眠?

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
  }

这篇关于如何Windows服务的行为进入/从睡眠状态唤醒或休眠模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆