Exemplo n.º 1
0
        private SqlDistributedLock(string lockName, IInternalSqlDistributedLock internalLock)
        {
            if (lockName == null)
            {
                throw new ArgumentNullException("lockName");
            }
            if (lockName.Length > MaxLockNameLength)
            {
                throw new FormatException("lockName: must be at most " + MaxLockNameLength + " characters");
            }

            this.internalLock = internalLock;
        }
Exemplo n.º 2
0
        private SqlDistributedSemaphore(string semaphoreName, int maxCount, Func <string, IInternalSqlDistributedLock> createInternalLockFromName)
        {
            if (semaphoreName == null)
            {
                throw new ArgumentNullException("lockName");
            }
            if (maxCount < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxCount), maxCount, "must be positive");
            }

            this.strategy     = new SqlSemaphore(maxCount);
            this.internalLock = createInternalLockFromName(SqlSemaphore.ToSafeName(semaphoreName));
        }
Exemplo n.º 3
0
 public OptimisticConnectionMultiplexingSqlDistributedLock(string lockName, string connectionString)
 {
     this.lockName         = lockName;
     this.connectionString = connectionString;
     this.fallbackLock     = new OwnedConnectionSqlDistributedLock(lockName: lockName, connectionString: connectionString);
 }