DbCommand.ExecuteNonQueryAsync DbCommand.ExecuteNonQueryAsync DbCommand.ExecuteNonQueryAsync DbCommand.ExecuteNonQueryAsync Method

定义

此方法实现 ExecuteNonQuery() 的异步版本,但阻塞调用线程时同步返回 TaskThis method implements the asynchronous version of ExecuteNonQuery(), but returns a Task synchronously, blocking the calling thread.

重载

ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken)

这是 ExecuteNonQuery() 的异步版本。This is the asynchronous version of ExecuteNonQuery(). 提供程序应使用合适的实现进行重写。Providers should override with an appropriate implementation. 可选择性忽略取消标记。The cancellation token may optionally be ignored.

默认实现调用同步 ExecuteNonQuery() 方法并返回已完成任务,以便阻止调用线程。The default implementation invokes the synchronous ExecuteNonQuery() 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. ExecuteNonQuery() 引发的异常将通过任务异常属性传递。Exceptions thrown by ExecuteNonQuery() will be communicated via the returned Task Exception property.

在返回的任务完成前,不要调用 DbCommand 对象的其他方法和属性。Do not invoke other methods and properties of the DbCommand object until the returned Task is complete.

ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync()

ExecuteNonQuery()的异步版本,针对一个连接对象执行一个 SQL 声明。An asynchronous version of ExecuteNonQuery(), which executes a SQL statement against a connection object.

通过 CancellationToken.None 调用 ExecuteNonQueryAsync(CancellationToken)Invokes ExecuteNonQueryAsync(CancellationToken) with CancellationToken.None.

注解

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

ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken) ExecuteNonQueryAsync(CancellationToken)

这是 ExecuteNonQuery() 的异步版本。This is the asynchronous version of ExecuteNonQuery(). 提供程序应使用合适的实现进行重写。Providers should override with an appropriate implementation. 可选择性忽略取消标记。The cancellation token may optionally be ignored.

默认实现调用同步 ExecuteNonQuery() 方法并返回已完成任务,以便阻止调用线程。The default implementation invokes the synchronous ExecuteNonQuery() 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. ExecuteNonQuery() 引发的异常将通过任务异常属性传递。Exceptions thrown by ExecuteNonQuery() will be communicated via the returned Task Exception property.

在返回的任务完成前,不要调用 DbCommand 对象的其他方法和属性。Do not invoke other methods and properties of the DbCommand object until the returned Task is complete.

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

参数

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests.

返回

表示异步操作的任务。A task representing the asynchronous operation.

异常

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

注解

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

另请参阅

ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync() ExecuteNonQueryAsync()

ExecuteNonQuery()的异步版本,针对一个连接对象执行一个 SQL 声明。An asynchronous version of ExecuteNonQuery(), which executes a SQL statement against a connection object.

通过 CancellationToken.None 调用 ExecuteNonQueryAsync(CancellationToken)Invokes ExecuteNonQueryAsync(CancellationToken) with CancellationToken.None.

public:
 System::Threading::Tasks::Task<int> ^ ExecuteNonQueryAsync();
public System.Threading.Tasks.Task<int> ExecuteNonQueryAsync ();
member this.ExecuteNonQueryAsync : unit -> System.Threading.Tasks.Task<int>
Public Function ExecuteNonQueryAsync () As Task(Of Integer)

返回

表示异步操作的任务。A task representing the asynchronous operation.

异常

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

注解

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

另请参阅

适用于