Show / Hide Table of Contents

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()

Extension Methods

CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾