mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-11 19:01:00 +08:00
- 补充 ObjectPool Async CancellationToken 参数;#2177
This commit is contained in:
@@ -12,6 +12,7 @@ using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
|
||||
namespace FreeSql.Oracle
|
||||
{
|
||||
@@ -164,7 +165,7 @@ namespace FreeSql.Oracle
|
||||
|
||||
#if net40
|
||||
#else
|
||||
async public Task OnGetAsync(Object<DbConnection> obj)
|
||||
async public Task OnGetAsync(Object<DbConnection> obj, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (_pool.IsAvailable)
|
||||
@@ -175,12 +176,12 @@ namespace FreeSql.Oracle
|
||||
throw new Exception(CoreErrorStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync(false, cancellationToken)) == false)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
await obj.Value.OpenAsync();
|
||||
await obj.Value.OpenAsync(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -241,11 +242,11 @@ namespace FreeSql.Oracle
|
||||
|
||||
#if net40
|
||||
#else
|
||||
async public static Task<bool> PingAsync(this DbConnection that, bool isThrow = false)
|
||||
async public static Task<bool> PingAsync(this DbConnection that, bool isThrow = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
await PingCommand(that).ExecuteNonQueryAsync();
|
||||
await PingCommand(that).ExecuteNonQueryAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user