Skip to content

Commit

Permalink
Improve documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Oct 1, 2024
1 parent e23fa19 commit 9c57b3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ void DoThat()
If you want to avoid limiting what you are able to do, you need a solution such as this library.

## Usage
### If only targeting .NET 5.0 or later
There are two methods for using this library, one that is clean but not hardened against thread aborts (which were removed since .NET 5.0), and another one that requires more work and the use of a factory method.

If you are only targeting .NET 5.0 or greater, then you are strongly recommended to use the [clean method](#net50-or-greater).
If you need to target frameworks prior to .NET 5.0 (and that would also include .NET Standard 2.0 and 2.1), then you need to use the [factory method](#prior-to-net50).

### <a name="net50-or-greater"></a>Clean method: (if only targeting .NET 5.0 or greater)
Use this library the same way you would use [System.Threading.Lock](https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock?view=net-9.0).

In order to get the performance benefits of `System.Threading.Lock`, you must however [multi-target frameworks](https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file) in your `.csproj` file.
Expand All @@ -68,7 +73,7 @@ There is also no need to reference this library as a dependency for .NET 9.0+. Y
</ItemGroup>
```

### If targeting frameworks prior to .NET 5.0
### <a name="prior-to-net50"></a>Factory method: (if targeting frameworks prior to .NET 5.0)
Due to frameworks prior to .NET 5.0 supporting the notorious `Thread.Abort`, we cannot use the same `System.Threading.Lock` namespace or else the locks would not be hardened against thread aborts, so we need to use a creator method instead.

You must also [multi-target](https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file) .NET 9.0 in your `.csproj` file as well.
Expand Down

0 comments on commit 9c57b3b

Please sign in to comment.