System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: f4d358993cbc69b7d03e3a1f93bbe1ad2c07ef0d
Title: Provide an implementation of OpenAsync
Status: Open Type: Feature_Request
Severity: Important Priority: Medium
Subsystem: Connection Resolution: Under_Review
Last Modified: 2016-03-21 23:03:38
Version Found In:
User Comments:
anonymous added on 2016-03-21 19:50:33: (text/x-fossil-plain)
When a provider inherit from System.Data.Common.DbConnection, it should overwrites the OpenAsync method to provides a native implementation. Elsewhere, calling the OpenAsync method will be the same as calling the Open method.

    /// <summary>
    /// This is the asynchronous version of <see cref="M:System.Data.Common.DbConnection.Open"/>. Providers should override with an appropriate implementation. The cancellation token can optionally be honored.The default implementation invokes the synchronous <see cref="M:System.Data.Common.DbConnection.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.
    /// </summary>
    /// 
    /// <returns>
    /// A task representing the asynchronous operation.
    /// </returns>
    /// <param name="cancellationToken">The cancellation instruction.</param>
    public virtual Task OpenAsync(CancellationToken cancellationToken)
    {
      TaskCompletionSource<object> completionSource = new TaskCompletionSource<object>();
      if (cancellationToken.IsCancellationRequested)
      {
        completionSource.SetCanceled();
      }
      else
      {
        try
        {
          this.Open();
          completionSource.SetResult((object) null);
        }
        catch (Exception ex)
        {
          completionSource.SetException(ex);
        }
      }
      return (Task) completionSource.Task;
    }