This documentation is archived and is not being maintained.

ServiceBase.OnShutdown Method

When implemented in a derived class, executes when the system is shutting down. Specifies what should happen immediately prior to the system shutting down.

[Visual Basic]
Protected Overridable Sub OnShutdown()
protected virtual void OnShutdown();
protected: virtual void OnShutdown();
protected function OnShutdown();


Use OnShutdown to specify the processing that occurs when the system shuts down. Often, OnShutdown will be similar to the processing in OnStop. This event occurs only when the operating system is shut down, not when the computer is turned off.

OnShutdown is expected to be overridden when the CanShutdown property is true.


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 | CanShutdown | OnContinue | OnPause | OnPowerEvent | OnStart | OnStop | OnCustomCommand