- 补充 ObjectPool Async CancellationToken 参数;#2177

This commit is contained in:
2881099
2025-12-22 23:07:22 +08:00
parent 04a2d95f19
commit 88b4e7693e
25 changed files with 138 additions and 206 deletions

View File

@@ -2,10 +2,10 @@
using FreeSql.Internal.ObjectPool;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Firebird
@@ -124,7 +124,7 @@ namespace FreeSql.Firebird
#if net40
#else
async public Task OnGetAsync(Object<DbConnection> obj)
async public Task OnGetAsync(Object<DbConnection> obj, CancellationToken cancellationToken)
{
if (_pool.IsAvailable)
@@ -133,7 +133,7 @@ namespace FreeSql.Firebird
throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name));
if (obj.Value.State != ConnectionState.Open)
await obj.Value.OpenAsync();
await obj.Value.OpenAsync(cancellationToken);
}
}
#endif
@@ -183,23 +183,5 @@ namespace FreeSql.Firebird
return false;
}
}
#if net40
#else
async public static Task<bool> PingAsync(this DbConnection that, bool isThrow = false)
{
try
{
await PingCommand(that).ExecuteNonQueryAsync();
return true;
}
catch
{
if (that.State != ConnectionState.Closed) try { that.Close(); } catch { }
if (isThrow) throw;
return false;
}
}
#endif
}
}