Use System.Threading.Lock throughout ASP.NET Core #56794
Labels
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Perf
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
.NET 9 added a new lock type: dotnet/runtime#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 theLock
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
The text was updated successfully, but these errors were encountered: