ServiceController.CanShutdown Property

Definition

Gets a value indicating whether the service should be notified when the system is shutting down.

C#
public bool CanShutdown { get; }
C#
[System.ServiceProcess.ServiceProcessDescription("SPCanShutdown")]
public bool CanShutdown { get; }

Property Value

true if the service should be notified when the system is shutting down; otherwise, false.

Attributes

Exceptions

An error occurred when accessing a system API.

The service was not found.

Examples

The following example demonstrates the use of the CanShutdown property to determine whether a service provides a handler for a shutdown event. This example is part of a larger example that is provided for the ServiceController class.

C#
// Display properties for the Simple Service sample
// from the ServiceBase example.
ServiceController sc = new ServiceController("Simple Service");
Console.WriteLine("Status = " + sc.Status);
Console.WriteLine("Can Pause and Continue = " + sc.CanPauseAndContinue);
Console.WriteLine("Can ShutDown = " + sc.CanShutdown);
Console.WriteLine("Can Stop = " + sc.CanStop);

Applies to

Product Versions
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 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
.NET Standard 2.0 (package-provided)