Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用 C# 编写的服务,当计算机进入睡眠模式时,它似乎并没有完全关闭。用户需要手动停止并重新启动服务以保留功能。我知道问题是什么,但我不知道在哪里解决它。Windows 服务在进入/退出睡眠和休眠时的行为如何?
服务如何对电源事件做出反应?真的,这取决于。
在您的服务中,您可以通过在您的服务中处理它来处理休眠/挂起/等事件
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { //do stuff here }