Επεξεργασία

Κοινή χρήση μέσω


DbDataSource.OpenDbConnectionAsync(CancellationToken) Method

Definition

Asynchronously returns a new, open connection to the database represented by this DbDataSource.

protected virtual System.Threading.Tasks.ValueTask<System.Data.Common.DbConnection> OpenDbConnectionAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member OpenDbConnectionAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Data.Common.DbConnection>
override this.OpenDbConnectionAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Data.Common.DbConnection>
Protected Overridable Function OpenDbConnectionAsync (Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of DbConnection)

Parameters

cancellationToken
CancellationToken

A token to cancel the asynchronous operation.

Returns

A new, open connection to the database represented by this DbDataSource.

Exceptions

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

Remarks

This method is meant to be overridden by implementing ADO.NET providers, and is not a user-facing API.

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 OpenDbConnection().

Applies to