This documentation is archived and is not being maintained.

ServiceBase.CanShutdown Property

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

[Visual Basic]
Public Property CanShutdown As Boolean
public bool CanShutdown {get; set;}
public: __property bool get_CanShutdown();
public: __property void set_CanShutdown(bool);
public function get CanShutdown() : Boolean;
public function set CanShutdown(Boolean);

Property Value

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


Exception Type Condition
InvalidOperationException The service has already been started. The CanShutdown property cannot be changed once the service has started.


If CanShutdown is true, the service is notified when the system is shutting down. At shutdown, the OnShutdown method is called if it has been implemented in your derived class.

Note   Only the system should cause the OnShutdown method to execute; the service can call it, but this is not recommended.


Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

ServiceBase Class | ServiceBase Members | System.ServiceProcess Namespace | OnShutdown | CanPauseAndContinue | CanStop | CanHandlePowerEvent