DbDataReader.ReadAsync 方法

定义

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

重载

ReadAsync()

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

ReadAsync(CancellationToken)

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

注解

有关异步编程的详细信息,请参阅异步编程For more information about asynchronous programming, see Asynchronous Programming.

ReadAsync()

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

public:
 System::Threading::Tasks::Task<bool> ^ ReadAsync();
public System.Threading.Tasks.Task<bool> ReadAsync ();
member this.ReadAsync : unit -> System.Threading.Tasks.Task<bool>
Public Function ReadAsync () As Task(Of Boolean)

返回

一个 Task<TResult>,如果有更多的行,则其 Result 属性为 true,如果没有,则为 falseA Task<TResult> whose Result property is true if there are more rows or false if there aren't.

异常

执行命令文本时出现的一个错误。An error occurred while executing the command text.

注解

此异步方法的默认实现调用其同步对应项,并返回已完成的任务,可能会阻止调用线程。The default implementation of this asynchronous method invokes its synchronous counterpart and returns a completed Task, potentially blocking the calling thread.

支持异步编程的数据访问接口应使用异步 i/o 操作来重写默认实现。Data providers that support asynchronous programming should override the default implementation using asynchronous I/O operations.

当返回任务还未完成时, DbDataReader 对象的其他方法和属性不应调用 。Other methods and properties of the DbDataReader object should not be invoked while the returned Task is not yet completed.

另请参阅

ReadAsync(CancellationToken)

使读取器异步前进到结果集中的下一条记录。Asynchronously advances the reader to the next record in a result set.

public:
 virtual System::Threading::Tasks::Task<bool> ^ ReadAsync(System::Threading::CancellationToken cancellationToken);
public virtual System.Threading.Tasks.Task<bool> ReadAsync (System.Threading.CancellationToken cancellationToken);
abstract member ReadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
override this.ReadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>

参数

cancellationToken
CancellationToken

取消指令。The cancellation instruction.

返回

一个 Task<TResult>,如果有更多的行,则其 Result 属性为 true,如果没有,则为 falseA Task<TResult> whose Result property is true if there are more rows or false if there aren't.

异常

执行命令文本时出现的一个错误。An error occurred while executing the command text.

注解

此异步方法的默认实现调用其同步对应项,并返回已完成的任务,可能会阻止调用线程。The default implementation of this asynchronous method invokes its synchronous counterpart and returns a completed Task, potentially blocking the calling thread. 如果传递了已取消的取消标记,则默认实现还会返回已取消的任务。The default implementation also returns a cancelled task if passed an already cancelled cancellation token.

支持异步编程的数据访问接口应使用异步 i/o 操作来重写默认实现。Data providers that support asynchronous programming should override the default implementation using asynchronous I/O operations.

该方法可用于请求操作之前接受取消标记。This method accepts a cancellation token that can be used to request the operation to be cancelled early. 实现可能会忽略该请求。Implementations may ignore this request.

当返回任务还未完成时, DbDataReader 对象的其他方法和属性不应调用 。Other methods and properties of the DbDataReader object should not be invoked while the returned Task is not yet completed.

另请参阅

适用于