Example #1
0
        private void Release()
        {
            if (this.transaction.Connection?.IsClosedOrBroken() ?? true)
            {
                // lost the connection or transaction disposed, so the lock was already released released
                return;
            }

            SqlApplicationLock.ExecuteReleaseCommand(new ConnectionOrTransaction(this.transaction), this.lockName);
        }
 private static void ReleaseLock(SqlConnection connection, string lockName)
 {
     try
     {
         // explicit release is required due to connection pooling. For a pooled connection,
         // simply calling Dispose() will not release the lock: it just returns the connection
         // to the pool
         SqlApplicationLock.ExecuteReleaseCommand(connection, lockName);
     }
     finally
     {
         connection.Dispose();
     }
 }