Oracle 客户端不会覆盖方法的异步版本。DbCommand
他们使用调用方法的非异步版本的默认实现。
例如,实现ExecuteNonQueryAsync
是:
// System.Data.Common.DbCommand
public virtual Task<int> ExecuteNonQueryAsync(CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return ADP.CreatedTaskWithCancellation<int>();
}
CancellationTokenRegistration cancellationTokenRegistration = default(CancellationTokenRegistration);
if (cancellationToken.CanBeCanceled)
{
cancellationTokenRegistration = cancellationToken.Register(new Action(this.CancelIgnoreFailure));
}
Task<int> result;
try
{
result = Task.FromResult<int>(this.ExecuteNonQuery());
}
catch (Exception ex)
{
cancellationTokenRegistration.Dispose();
result = ADP.CreatedTaskWithException<int>(ex);
}
return result;
}
如您所见,它只是在后台调用(调用此版本方法ExecuteNonQuery
的无参数重载)。ExecuteNonQueryAsync