#### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils 'index')
### [System\.Threading](https://www.abblix.com/en/docs/api/abblix-utils/System.Threading 'System\.Threading')

## Lock Class

Stands in for `System.Threading.Lock`, which arrived in \.NET 9\.

```csharp
public sealed class Lock
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Lock

### Remarks
Lets a single source file use the newer mutual\-exclusion type across every target this library supports\.
On \.NET 9 and later the real type is used, and the compiler lowers `lock` on it to
[EnterScope\(\)](https://www.abblix.com/en/docs/api/abblix-utils/System.Threading.Lock#System.Threading.Lock.EnterScope() 'System\.Threading\.Lock\.EnterScope\(\)'); on \.NET 8 this stands in and the same statement lowers to `Monitor`, which
is what the code would have used anyway\.

The shape mirrors the real type only as far as `lock` needs, because that is all this exists for:
nothing should take a dependency on a polyfill beyond the syntax it enables\.
### Methods

## Lock\.EnterScope\(\) Method {#System.Threading.Lock.EnterScope()}

Enters the lock, returning a scope that leaves it when disposed\.

```csharp
public System.Threading.Lock.Scope EnterScope();
```

#### Returns
[Scope](https://www.abblix.com/en/docs/api/abblix-utils/System.Threading.Lock.Scope 'System\.Threading\.Lock\.Scope')
