optimize AdoProvider.Dispose

This commit is contained in:
28810
2020-06-11 18:21:18 +08:00
parent 03b9ad6ff5
commit 117ef11274
2 changed files with 175 additions and 149 deletions

View File

@ -132,8 +132,8 @@ namespace FreeSql.Internal.CommonProvider
if (Interlocked.Increment(ref _disposeCounter) != 1) return;
try
{
var trans = _trans.Values.ToArray();
foreach (var tran in trans) CommitTransaction(false, tran, null, "Dispose自动提交");
var trans = _trans?.Values.ToArray();
if (trans != null) foreach (var tran in trans) CommitTransaction(false, tran, null, "Dispose自动提交");
}
catch { }
@ -142,8 +142,8 @@ namespace FreeSql.Internal.CommonProvider
{
try
{
pools = SlavePools.ToArray();
SlavePools.Clear();
pools = SlavePools?.ToArray();
SlavePools?.Clear();
break;
}
catch
@ -154,10 +154,10 @@ namespace FreeSql.Internal.CommonProvider
{
foreach (var pool in pools)
{
try { pool.Dispose(); } catch { }
try { pool?.Dispose(); } catch { }
}
}
try { MasterPool.Dispose(); } catch { }
try { MasterPool?.Dispose(); } catch { }
}
}
}