PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.AutoLocker Class Reference

Class to use the using() {} pattern to take care of locking / unlocking one of: More...

Inheritance diagram for PeanutButter.Utils.AutoLocker:

Public Member Functions

 AutoLocker (Semaphore semaphore)
 Constructs a new AutoLocker, immediately locking the provided Semaphore.
 AutoLocker (Semaphore semaphore, Action onDisposed)
 Constructs a new AutoLocker, immediately locking the provided Semaphore, with an OnDisposed event handler.
 AutoLocker (SemaphoreSlim semaphore)
 Constructs a new AutoLocker, immediately locking the provided SemaphoreSlim.
 AutoLocker (SemaphoreSlim semaphore, Action onDisposed)
 Constructs a new AutoLocker, immediately locking the provided SemaphoreSlim, with an OnDisposed event handler.
 AutoLocker (Mutex mutex)
 Constructs a new AutoLocker, immediately locking the provided Mutex.
 AutoLocker (Mutex mutex, Action onDisposed)
 Constructs a new AutoLocker, immediately locking the provided Mutex, with an OnDisposed event handler.
void Dispose ()

Properties

EventHandler OnDisposed [get, set]
 Subscribe to this to be notified when this locker is disposed, or pass an action in on the constructor.

Detailed Description

Class to use the using() {} pattern to take care of locking / unlocking one of:

  • Semaphore
  • SemaphoreSlim
  • Mutex without the consumer having to worry about unlocking in the event of exception handling

Constructor & Destructor Documentation

◆ AutoLocker() [1/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( Semaphore semaphore)

Constructs a new AutoLocker, immediately locking the provided Semaphore.

Parameters
semaphoreSemaphore to lock immediately
Exceptions
ArgumentNullExceptionThrows ArgumentNullException if the provided Semaphore is null

◆ AutoLocker() [2/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( Semaphore semaphore,
Action onDisposed )

Constructs a new AutoLocker, immediately locking the provided Semaphore, with an OnDisposed event handler.

Parameters
semaphore
onDisposed
Exceptions
ArgumentNullException

◆ AutoLocker() [3/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( SemaphoreSlim semaphore)

Constructs a new AutoLocker, immediately locking the provided SemaphoreSlim.

Parameters
semaphoreSemaphoreSlim to lock immediately
Exceptions
ArgumentNullExceptionThrown if the provided SemaphoreSlim is null

◆ AutoLocker() [4/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( SemaphoreSlim semaphore,
Action onDisposed )

Constructs a new AutoLocker, immediately locking the provided SemaphoreSlim, with an OnDisposed event handler.

Parameters
semaphore
onDisposed
Exceptions
ArgumentNullException

◆ AutoLocker() [5/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( Mutex mutex)

Constructs a new AutoLocker, immediately locking the provided Mutex.

Parameters
mutexMutex to lock immediately
Exceptions
ArgumentNullExceptionThrown if the provided Mutex is null

◆ AutoLocker() [6/6]

PeanutButter.Utils.AutoLocker.AutoLocker ( Mutex mutex,
Action onDisposed )

Constructs a new AutoLocker, immediately locking the provided Mutex, with an OnDisposed event handler.

Parameters
mutexMutex to lock immediately
onDisposed
Exceptions
ArgumentNullExceptionThrown if the provided Mutex is null

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/AutoLocker.cs