Ejemplo n.º 1
0
        public void Dispose()
        {
            if (_isdisposed)
            {
                return;
            }
            try {
                Transaction2[] trans = null;
                lock (_trans_lock)
                    trans = _trans.Values.ToArray();
                foreach (Transaction2 tran in trans)
                {
                    CommitTransaction(false, tran);
                }
            } catch { }

            ObjectPool <DbConnection>[] pools = null;
            for (var a = 0; a < 10; a++)
            {
                try {
                    pools = SlavePools.ToArray();
                    SlavePools.Clear();
                    break;
                } catch {
                }
            }
            if (pools != null)
            {
                foreach (var pool in pools)
                {
                    try { pool.Dispose(); } catch { }
                }
            }
            try { MasterPool.Dispose(); } catch { }
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (ResolveTransaction != null)
            {
                return;
            }
            if (Interlocked.Increment(ref _disposeCounter) != 1)
            {
                return;
            }
            try
            {
                var trans = _trans?.Values.ToArray();
                if (trans != null)
                {
                    foreach (var tran in trans)
                    {
                        CommitTransaction(false, tran, null, "Dispose自动提交");
                    }
                }
            }
            catch { }

            IObjectPool <DbConnection>[] pools = null;
            for (var a = 0; a < 10; a++)
            {
                try
                {
                    pools = SlavePools?.ToArray();
                    SlavePools?.Clear();
                    break;
                }
                catch
                {
                }
            }
            if (pools != null)
            {
                foreach (var pool in pools)
                {
                    try { pool?.Dispose(); } catch { }
                }
            }
            try { MasterPool?.Dispose(); } catch { }
        }