Application.SetSuspendState(PowerState, Boolean, Boolean) Method

Definition

Suspends or hibernates the system, or requests that the system be suspended or hibernated.

C#
public static bool SetSuspendState(System.Windows.Forms.PowerState state, bool force, bool disableWakeEvent);

Parameters

state
PowerState

A PowerState indicating the power activity mode to which to transition.

force
Boolean

true to force the suspended mode immediately; false to cause Windows to send a suspend request to every application.

disableWakeEvent
Boolean

true to disable restoring the system's power status to active on a wake event, false to enable restoring the system's power status to active on a wake event.

Returns

true if the system is being suspended, otherwise, false.

Remarks

If an application does not respond to a suspend request within 20 seconds, Windows determines that it is in a non-responsive state, and that the application can either be put to sleep or terminated. Once an application responds to a suspend request, however, it can take whatever time it needs to clean up resources and shut down active processes.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also