示例#1
0
        async ValueTask <WaitHandleDistributedSemaphoreHandle?> IInternalDistributedSemaphore <WaitHandleDistributedSemaphoreHandle> .InternalTryAcquireAsync(TimeoutValue timeout, CancellationToken cancellationToken)
        {
            var semaphore = await DistributedWaitHandleHelpers.CreateAndWaitAsync(
                createHandle : this.CreateSemaphore,
                abandonmentCheckCadence : this._abandonmentCheckCadence,
                timeout : timeout,
                cancellationToken : cancellationToken
                ).ConfigureAwait(false);

            return(semaphore != null ? new WaitHandleDistributedSemaphoreHandle(semaphore) : null);
        }
示例#2
0
        async ValueTask <EventWaitHandleDistributedLockHandle?> IInternalDistributedLock <EventWaitHandleDistributedLockHandle> .InternalTryAcquireAsync(
            TimeoutValue timeout,
            CancellationToken cancellationToken)
        {
            var @event = await DistributedWaitHandleHelpers.CreateAndWaitAsync(
                createHandle : this.CreateEvent,
                abandonmentCheckCadence : this._abandonmentCheckCadence,
                timeout : timeout,
                cancellationToken : cancellationToken
                ).ConfigureAwait(false);

            return(@event != null ? new EventWaitHandleDistributedLockHandle(@event) : null);
        }