Application.SetSuspendState(PowerState, Boolean, Boolean) 方法

定义

暂停或休眠系统,或请求系统暂停或休眠。

public:
 static bool SetSuspendState(System::Windows::Forms::PowerState state, bool force, bool disableWakeEvent);
public static bool SetSuspendState(System.Windows.Forms.PowerState state, bool force, bool disableWakeEvent);
static member SetSuspendState : System.Windows.Forms.PowerState * bool * bool -> bool
Public Shared Function SetSuspendState (state As PowerState, force As Boolean, disableWakeEvent As Boolean) As Boolean

参数

state
PowerState

指示 PowerState 要转换到的电源活动模式。

force
Boolean

true立即强制挂起模式;false导致Windows向每个应用程序发送暂停请求。

disableWakeEvent
Boolean

true 如果禁用将系统的电源状态还原到唤醒事件上处于活动状态, false 则启用将系统的电源状态还原为在唤醒事件上处于活动状态。

返回

如果系统正在挂起,则为 。

注解

如果应用程序在 20 秒内未响应暂停请求,Windows确定它处于非响应状态,并且应用程序可以进入睡眠状态或终止。 但是,应用程序响应暂停请求后,可能需要一段时间才能清理资源并关闭活动进程。

适用于

另请参阅