title: Return DataTable using async .net 4.0
body: <p>I have a method that returns a datatable. I thought using .net 4.0 I could just async logic and return data. But this code returns null Datatable object. Any ideas what is wrong with this code. </p>
  
  <pre><code>public DataTable GetData(string sql, string connectionName)
  {
      DataTable dt = (DataTable)GetDataAsync(sql, connectionName).AsyncState;
      return dt;
  }
  
  private async Task&lt;DataTable&gt; GetDataAsync(string sql, string connectionName)
  {
      return await TaskEx.Run(() =&gt; { return FillData(sql, connectionName); });
  }
  
  private DataTable FillData(string sql, string connectionName)
  {
      SqlConnection conn = _connections.Where(w =&gt; w.ConnectionName == connectionName).Single().Connection;
      SqlDataAdapter adp = new SqlDataAdapter(sql, conn);
      DataSet ds = new DataSet();
  
      adp.Fill(ds);
  
      return ds.Tables[0];
  }
  </code></pre>