Share via


SqlBatch.ExecuteNonQueryAsync(CancellationToken) Method

Definition

This is the asynchronous version of ExecuteNonQuery().

The implementation invokes the ExecuteNonQueryAsync(CancellationToken) method and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellation token.

Do not invoke other methods and properties of the DbCommand object until the returned Task is complete.

public override System.Threading.Tasks.Task<int> ExecuteNonQueryAsync (System.Threading.CancellationToken cancellationToken = default);
override this.ExecuteNonQueryAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
Public Overrides Function ExecuteNonQueryAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Parameters

cancellationToken
CancellationToken

A token to cancel the asynchronous operation.

Returns

A task representing the asynchronous operation.

Exceptions

An error occurred while executing the batch.

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

Remarks

For more information about asynchronous programming, see Asynchronous Programming.

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.

Note

This method benefits from ExecuteNonQueryAsync(CancellationToken), and all the expected exceptions of that method also apply here.

Applies to

See also