This method implements an asynchronous version of Open().
Overloads OpenAsync()An asynchronous version of Open(), which opens a database connection with the settings specified by the ConnectionString. This method invokes the virtual method OpenAsync(CancellationToken) with CancellationToken.None.
OpenAsync(CancellationToken)This is the asynchronous version of Open(). Providers should override with an appropriate implementation. The cancellation token can optionally be honored.
The default implementation invokes the synchronous Open() call and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by Open will be communicated via the returned Task Exception property.
Do not invoke other methods and properties of the DbConnection
object until the returned Task is complete.
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.
OpenAsync()public:
System::Threading::Tasks::Task ^ OpenAsync();
public System.Threading.Tasks.Task OpenAsync();
member this.OpenAsync : unit -> System.Threading.Tasks.Task
Public Function OpenAsync () As Task
Returns
A task representing the asynchronous operation.
RemarksAfter calling OpenAsync, State must return Connecting until the returned Task is completed. Then, if the connection was successful, State must return Open. If the connection fails, State must return Closed.
A call to Close will attempt to cancel or close the corresponding OpenAsync call.
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.
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 Open().
See also OpenAsync(CancellationToken)This is the asynchronous version of Open(). Providers should override with an appropriate implementation. The cancellation token can optionally be honored.
The default implementation invokes the synchronous Open() call and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by Open will be communicated via the returned Task Exception property.
Do not invoke other methods and properties of the DbConnection
object until the returned Task is complete.
public:
virtual System::Threading::Tasks::Task ^ OpenAsync(System::Threading::CancellationToken cancellationToken);
public virtual System.Threading.Tasks.Task OpenAsync(System.Threading.CancellationToken cancellationToken);
abstract member OpenAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.OpenAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function OpenAsync (cancellationToken As CancellationToken) As Task
Parameters Returns
A task representing the asynchronous operation.
ExceptionsThe cancellation token was canceled. This exception is stored into the returned task.
RemarksAfter calling OpenAsync, State must return Connecting until the returned Task is completed. Then, if the connection was successful, State must return Open. If the connection fails, State must return Closed.
A call to Close will attempt to cancel or close the corresponding OpenAsync call.
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.
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 Open().
See alsoCollaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4