dotnet / dotnet/dotnet-api-docs

Best practice in examples

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

Description

These examples ought to show the use of `try`/`finally` to ensure that `mutex.ReleaseMutex()` gets called even if an exception occurs. Without this pattern, if an exception occurs while the mutex is held, it will stay held, either indefinitely, or until the `Mutex` is `Dispose`d, at which point anyone else waiting for it will get a "mutex abandoned" exception.

---
#### Document Details

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

* ID: 8c9cb6ee-c640-f10c-94e5-8d0dc4fd2607
* Version Independent ID: 0ba90353-d332-30a1-9ed0-993630f0fc1c
* Content: [Mutex.ReleaseMutex Method (System.Threading)](https://docs.microsoft.com/en-us/dotnet/api/system.threading.mutex.releasemutex?view=netframework-4.7.2)
* Content Source: [xml/System.Threading/Mutex.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Threading/Mutex.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.