DbConnection.ChangeDatabaseAsync(String, CancellationToken) Method

Definition

Asynchronously changes the current database for an open connection.

public virtual System.Threading.Tasks.Task ChangeDatabaseAsync (string databaseName, System.Threading.CancellationToken cancellationToken = default);
abstract member ChangeDatabaseAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.ChangeDatabaseAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function ChangeDatabaseAsync (databaseName As String, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

databaseName
String

The name of the database for the connection to use.

cancellationToken
CancellationToken

An optional token to cancel the asynchronous operation. The default value is None.

Returns

Task

A task representing the asynchronous operation.

Remarks

The value supplied in the databaseName parameter must be a valid database name for the current instance.

The default implementation of this asynchronous method delegates to its synchronous counterpart and returns a completed Task, potentially blocking the calling thread.

Data providers that support asynchronous programming should override the default implementation using asynchronous I/O operations.

Applies to