Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 1.45 KB

DistributedLock.WaitHandles.md

File metadata and controls

27 lines (18 loc) · 1.45 KB

DistributedLock.WaitHandles

Download the NuGet package NuGet Status

The DistributedLock.WaitHandles package offers distributed locks based on global WaitHandles in Windows. This library only works on Windows. For example:

var @lock = new EventWaitHandleDistributedLock("MyLockName");
await using (await @lock.AcquireAsync())
{
  // I have the lock!
}

APIs

  • The EventWaitHandleDistributedLock class implements the IDistributedLock interface.
  • The WaitHandleDistributedSemaphore class implements the IDistributedSemaphore interface.
  • The WaitHandleDistributedSynchronizationProvider class implements the IDistributedLockProvider and IDistributedSemaphoreProvider interfaces.

Implementation notes

Because they are based on global EventWaitHandles/Semaphores, these classes are used to coordinate between processes on the same machine (as opposed to across machines).

Options

The optional abandonmentCheckCadence argument specifies how frequently the implementation will check to see if the original holder of a lock/semaphore abandoned it without properly releasing it while waiting for it to become available. Defaults to 2s.