Edit

Share via


SpinLockExtensions Class

Definition

Helpers for working with the SpinLock type.

public static class SpinLockExtensions
type SpinLockExtensions = class
Public Module SpinLockExtensions
Inheritance
SpinLockExtensions

Methods

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

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.

Applies to