Use System.Threading.Lock throughout ASP.NET Core
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
.NET 9 added a new lock type: https://github.com/dotnet/runtime/issues/34812. The benefits are some small performance improvements, and disambiguation about locking on any type.
We should see if we can use this in ASP.NET Core. Could be performance gains in lock heavy code.
### Describe the solution you'd like
The new type is only available in .NET 9 or later. However, some ASP.NET Core code targets back to .NET standard. It's not as simple as updating `private static readonly object _lock` fields with the `Lock` type because of this.
We could add a shim `Lock` type that is conditionally included in older targets. A shim type would avoid spreading `#ifdefs` throughout the code.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.