PreventShutdownContext Constructor

Initializes a new instance of the PreventShutdownContext class.

Definition

Namespace: DevCase.Core.IO.Devices.Power
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public PreventShutdownContext(
	string reason,
	bool throwOnError = true
)

Parameters

reason  String
The reason for which the current application must prevent system shutdown.

Because users are typically in a hurry when shutting down the system, they may spend only a few seconds looking at the shutdown reasons that are displayed by the system. Therefore, it is important that your reason strings are short and clear.

throwOnError  Boolean  (Optional)
If , an exception will be thrown if the application does not meet the requirements to prevent a system shutdown.

Default value is .

Exceptions

InvalidOperationException Applications without a user interface can't prevent a system shutdown.
InvalidOperationException The main window of the current application is not yet created or is not visible.
InvalidOperationException Only the thread that created the main window of the current application can call this to prevent a system shutdown.
SecurityException The user does not have the permissions required to create or modify 'AutoEndTasks' registry value. Therefore, the application can't prevent a system shutdown.

See Also