Edit

Share via


SpinLockExtensions.Enter Method

Definition

Overloads

Enter(SpinLock)

Enters a specified SpinLock instance and returns a wrapper to use to release the lock. This extension should be used though a using block or statement:

SpinLock spinLock = new SpinLock();

using (spinLock.Enter())
{
    // Thread-safe code here...
}

The compiler will take care of releasing the SpinLock when the code goes out of that using scope.

Enter(SpinLock*)
Obsolete.

Enters a specified SpinLock instance and returns a wrapper to use to release the lock. This extension should be used though a using block or statement:

SpinLock spinLock = new SpinLock();

using (SpinLockExtensions.Enter(&spinLock))
{
    // Thread-safe code here...
}

The compiler will take care of releasing the SpinLock when the code goes out of that using scope.

Enter(Object, SpinLock)

Enter(SpinLock)

Source:
SpinLockExtensions.cs

Enters a specified SpinLock instance and returns a wrapper to use to release the lock. This extension should be used though a using block or statement:

SpinLock spinLock = new SpinLock();

using (spinLock.Enter())
{
    // Thread-safe code here...
}

The compiler will take care of releasing the SpinLock when the code goes out of that using scope.

public static CommunityToolkit.HighPerformance.SpinLockExtensions.Lock Enter(this ref System.Threading.SpinLock spinLock);
static member Enter : SpinLock -> CommunityToolkit.HighPerformance.SpinLockExtensions.Lock
<Extension()>
Public Function Enter (ByRef spinLock As SpinLock) As SpinLockExtensions.Lock

Parameters

spinLock
SpinLock

The target SpinLock to use

Returns

A wrapper type that will release spinLock when its Dispose() method is called.

Remarks

The returned SpinLockExtensions.Lock value shouldn't be used directly: use this extension in a using block or statement.

Applies to

Enter(SpinLock*)

Source:
SpinLockExtensions.cs
Source:
SpinLockExtensions.cs

Caution

Use SpinLockExtensions.Enter(ref SpinLock) instead.

Enters a specified SpinLock instance and returns a wrapper to use to release the lock. This extension should be used though a using block or statement:

SpinLock spinLock = new SpinLock();

using (SpinLockExtensions.Enter(&spinLock))
{
    // Thread-safe code here...
}

The compiler will take care of releasing the SpinLock when the code goes out of that using scope.

[System.Obsolete("Use SpinLockExtensions.Enter(ref SpinLock) instead.")]
public static CommunityToolkit.HighPerformance.SpinLockExtensions.UnsafeLock Enter(System.Threading.SpinLock* spinLock);
public static CommunityToolkit.HighPerformance.SpinLockExtensions.UnsafeLock Enter(System.Threading.SpinLock* spinLock);
[<System.Obsolete("Use SpinLockExtensions.Enter(ref SpinLock) instead.")>]
static member Enter : nativeptr<System.Threading.SpinLock> -> CommunityToolkit.HighPerformance.SpinLockExtensions.UnsafeLock
static member Enter : nativeptr<System.Threading.SpinLock> -> CommunityToolkit.HighPerformance.SpinLockExtensions.UnsafeLock

Parameters

spinLock
SpinLock*

A pointer to the target SpinLock to use

Returns

A wrapper type that will release spinLock when its Dispose() method is called.

Attributes

Remarks

The returned SpinLockExtensions.UnsafeLock value shouldn't be used directly: use this extension in a using block or statement.

Applies to

Enter(Object, SpinLock)

Source:
SpinLockExtensions.cs
public static CommunityToolkit.HighPerformance.SpinLockExtensions.Lock Enter(object owner, ref System.Threading.SpinLock spinLock);
static member Enter : obj * SpinLock -> CommunityToolkit.HighPerformance.SpinLockExtensions.Lock
Public Shared Function Enter (owner As Object, ByRef spinLock As SpinLock) As SpinLockExtensions.Lock

Parameters

owner
Object
spinLock
SpinLock

Returns

Applies to