title: C# SQL connection OpenAsync is not asynchronous
body: <p>I'm trying to open a connection to an SQL server asynchronously, so as not to tie up the UI thread. But I've found that the call to <code>connection.OpenAsync()</code> does not return until the connection has been opened, exactly as with <code>connection.Open()</code>.</p>
  
  <p>This code reproduces the issue:</p>
  
  <pre><code>public static void Main(string[] args)
  {
      System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
      builder.UserID = "sa";
      builder.Password = "1234";
      builder.DataSource = "192.168.1.254\\SQLEXPRESS";
      builder.InitialCatalog = "MyDatabase";
      builder.PersistSecurityInfo = true;
  
      DbConnection connection = new System.Data.SqlClient.SqlConnection(builder.ConnectionString);
  
      Console.WriteLine("about to connect");
  
      Task connection_task = connection.OpenAsync();
  
      Console.WriteLine("started");
  
      while (!connection_task.IsCompleted &amp;&amp; !connection_task.IsFaulted &amp;&amp; !connection_task.IsCanceled)
      {
          Console.WriteLine("busy");
      }
  
      Console.WriteLine("done");
  }
  </code></pre>
  
  <p>In this case, <code>192.168.1.254</code> is non-existent. The message <code>about to connect</code> appears immediately, but then while waiting for the connection to time out nothing happens, then after the connection times out the messages <code>started</code> and <code>done</code> appear at the same time. I would expect that the message <code>started</code> would appear immediately after the message <code>about to connect</code>, then the message <code>done</code> would appear later once the connection has timed out.</p>
  
  <p>I'm guessing that I'm doing something wrong with the returned <code>Task</code>, but the Microsoft page on <a href="https://docs.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/task-based-asynchronous-pattern-tap" rel="nofollow noreferrer">Task-based Asynchronous Pattern</a> certainly implies that I should simply be able to call the <code>OpenAsync()</code> method and the returned <code>Task</code> will be running asynchronously, instead of the operation taking place synchronously and tying up the calling thread until the <code>Task</code> completes.</p>