Table of Contents

Class LockExtension

Namespace
DMediatR
Assembly
DMediatR.dll
public static class LockExtension
Inheritance
LockExtension
Inherited Members

Methods

Lock(ILock, SemaphoreSlim, CancellationToken)

Lock the given semaphore only once in a call chain to avoid deadlocks. It is the responsibility of the issuer of a message to relay the HasLocked HashSet of the ILockingMessage down to potentially recursive successive messages.

public static Task<bool> Lock(this ILock message, SemaphoreSlim semaphore, CancellationToken cancellationToken)

Parameters

message ILock
semaphore SemaphoreSlim

SemaphoreSlim(1,1) object of the handler class.

cancellationToken CancellationToken

Returns

Task<bool>

True if a lock has been acquired on the semaphore that finally must be released by the caller.