Bewerken

Share via


DbCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) Method

Definition

Providers should implement this method to provide a non-default implementation for ExecuteReader overloads.

The default implementation invokes the synchronous ExecuteReader() method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellation token. Exceptions thrown by ExecuteReader will be communicated via the returned Task Exception property.

This method accepts a cancellation token that can be used to request the operation to be cancelled early. Implementations may ignore this request.

protected:
 virtual System::Threading::Tasks::Task<System::Data::Common::DbDataReader ^> ^ ExecuteDbDataReaderAsync(System::Data::CommandBehavior behavior, System::Threading::CancellationToken cancellationToken);
protected virtual System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync (System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken);
abstract member ExecuteDbDataReaderAsync : System.Data.CommandBehavior * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.Common.DbDataReader>
override this.ExecuteDbDataReaderAsync : System.Data.CommandBehavior * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.Common.DbDataReader>
Protected Overridable Function ExecuteDbDataReaderAsync (behavior As CommandBehavior, cancellationToken As CancellationToken) As Task(Of DbDataReader)

Parameters

behavior
CommandBehavior

An instance of CommandBehavior, specifying options for command execution and data retrieval.

cancellationToken
CancellationToken

A token to cancel the asynchronous operation.

Returns

A task representing the asynchronous operation.

Exceptions

An error occurred while executing the command.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

For more information about asynchronous programming, see Asynchronous Programming.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ExecuteDbDataReader(CommandBehavior).

Applies to

See also