dotnet / dotnet/dotnet-api-docs

OnShutdown details

Open
#859 0 comments 0 reactions 0 assignees View on GitHub
area-System.ServiceProcess dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

If the computer is shutting down, does the OnStop() method also get called? If so, which is called first? If not, is it good practice to implement OnShutdown() with the same code as OnStop()? If we override OnShutdown(), but don't set CanShutdown to true, would the OnShutdown() method never get called?

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 687bc00c-c514-6f5e-42af-47367a7372ec
* Version Independent ID: 149780c2-ba44-cbca-c4ef-4acd9365a3b7
* Content: [ServiceBase.OnShutdown Method (System.ServiceProcess)](https://docs.microsoft.com/en-us/dotnet/api/system.serviceprocess.servicebase.onshutdown?view=netframework-4.7.2)
* Content Source: [xml/System.ServiceProcess/ServiceBase.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.ServiceProcess/ServiceBase.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.