Class SpinLockSection
Helper struct to avoid boilerplate with System.Threading.SpinLock. Only available for .NET 7.0+ and C# 11+. Normally you need to use following code:
bool lockTaken = false;
try
{
spinLock.Enter(ref lockTaken);
DoWithLock();
}
finally
{
if (lockTaken)
spinLock.Exit();
}
but using SpinLockSection can simplify to
using (spinLock.EnterDisposableLock())
DoWithLock();
Inheritance
System.Object
SpinLockSection
Namespace: Eco.Shared.Concurrent
Assembly: Eco.Shared.dll
Syntax
public sealed class SpinLockSection : ValueType
Methods
Dispose()
Declaration
public void Dispose()