title: Can the Oracle managed driver use async/await properly?
body: <p>I was trying to make an Oracle query with the async/await .NET feature. The result set is pretty large and takes about 5-10 seconds to come back. The <code>Window_Loaded</code> is hanging the UI thread, essentially I wanted to use async/wait to do the query in the background and then update a dataview with the result.</p>
  <p>So is this an Oracle driver issue or a code error? E.g. is something here being done synchronously instead of asynchronously?  I'm using the latest <code>Oracle.ManagedDataAccess</code> I could get from Oracle's web-site.</p>
  <pre><code>async Task&lt;DataTable&gt; AccessOracleAsync()
  {
      DataTable dt;
      using(OracleConnection conn = new OracleConnection(ConfigurationManager
          .ConnectionStrings[&quot;connStr&quot;].ConnectionString))
      using (OracleCommand cmd = new OracleCommand(@&quot;SELECT * FROM myTbl&quot;, conn))
      {
          await conn.OpenAsync();
          using (var reader = await cmd.ExecuteReaderAsync())
          {
              dt = new DataTable();
              dt.Load(reader);                        
          }
      }
      return dt;
  }
  
  private async void Window_Loaded(object sender, RoutedEventArgs e)
  {
      await AccessOracleAsync();
  }
  </code></pre>
  <hr />
  <p>I tried this, and it is still blocking the UI:</p>
  <pre><code>async Task&lt;DataView&gt; AccessOracleAsync()
  {
      DataTable dt;
      using (OracleConnection conn = new OracleConnection(ConfigurationManager
          .ConnectionStrings[&quot;connStr&quot;].ConnectionString))
      using (OracleCommand cmd = new OracleCommand(@&quot;SELECT * FROM myTbl&quot;, conn))
      {
          await conn.OpenAsync().ConfigureAwait(false);
          using (DbDataReader reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false))
          {
              dt = new DataTable();
              await Task.Run(() =&gt; dt.Load(reader)).ConfigureAwait(false);
          }
      }
      return dt.AsDataView();
  }
  
  private async void Window_Loaded(object sender, RoutedEventArgs e)
  {
      Data1.ItemsSource = await AccessOracleAsync();
  }
  </code></pre>
  <hr />
  <p>So in the end, I changed the method to something like this to make it not block. It appears I had the right idea, just that the Oracle managed library implemented the Async methods synchronously (only to comply with the interface).</p>
  <pre><code>private async Task&lt;DataView&gt; AccessOracleAsync()
  {
      DataTable dt = new DataTable();
      using (OracleConnection conn = new OracleConnection(ConfigurationManager
          .ConnectionStrings[&quot;connStr&quot;].ConnectionString))
      using (OracleCommand cmd = new OracleCommand(@&quot;SELECT * myTbl&quot;, conn))
      {
          await Task.Run(() =&gt;
          {
              conn.Open();
              using (DbDataReader reader = cmd.ExecuteReader())
              {
                  dt.Load(reader);
              }
          }).ConfigureAwait(false);
      }
      return dt.AsDataView();
  }
  </code></pre>