コード例 #1
0
 public IDisposable AcquireLock(LockType lockType, string instanceId)
 {
     while (true)
     {
         EnsureObjectNotDisposed();
         if (_lockRepository.TryAcquireLock(lockType, instanceId))
         {
             var lockInstance = new LockInstance(this, lockType, instanceId);
             AddLock(lockInstance);
             return(lockInstance);
         }
         Thread.Sleep(SleepThreshold);
     }
 }
コード例 #2
0
        private async Task ReleaseLock(LockInstance lockInstance)
        {
            await _pendingLocksSemaphore.WaitAsync();

            try
            {
                _lockRepository.ReleaseLock(lockInstance.LockType, lockInstance.InstanceId).ConfigureAwait(false).GetAwaiter().GetResult();

                LockReleased(lockInstance);
            }
            finally
            {
                _pendingLocksSemaphore.Release();
            }
        }
コード例 #3
0
            //****************************************

            internal Instance(LockInstance instance)
            {
                _Instance = instance;
                _Token    = instance.Version;
            }