dotnet / dotnet/dotnet-api-docs

Does Environment.Exit execute finally blocks?

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

Description

In Environment.FailFast Documentation it states:

> Use the FailFast method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair, and executing your application's try/finally blocks and finalizers will corrupt program resources.

Implying Exit does execute finally blocks. But in Exit documentation it states:

> If Exit is called from a try or catch block, the code in any finally block does not execute. If the return statement is used, the code in the finally block does execute.

Implying the opposite.

---
#### Document Details

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

* ID: ae3f15b2-a584-480d-0a04-bd97bfd9bbf6
* Version Independent ID: 7db4a5ef-dd70-2556-af9b-bc5f9b9230a4
* Content: [Environment.FailFast Method (System)](https://docs.microsoft.com/en-us/dotnet/api/system.environment.failfast?view=netframework-4.7.2)
* Content Source: [xml/System/Environment.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System/Environment.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.