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 = null);
abstract member ChangeDatabaseAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.ChangeDatabaseAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.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

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 inmplementation using asynchronous I/O operations.

Applies to