title: UI still freezing when using async/await
body: <p>I'm no expert in terms of asychronous operations and hoping that someone can help me point out the problem.</p>
  
  <p>In one of my methods I have written a wrapper,</p>
  
  <pre><code>public static async Task&lt;int&gt; ExecuteNonQueryRawSQLAsync(string sqlStatement)
  {
      int _returnValue = -1;
      using (SqlConnection _conn = new SqlConnection("connectionString"))
      {
          using (SqlCommand _comm = new SqlCommand())
          {
              _comm.Connection = _conn;
              _comm.CommandText = sqlStatement;
              _comm.CommandType = CommandType.Text;
  
              // other codes on setting parameter
  
              try
              {
                  await _conn.OpenAsync();
                  _returnValue = Convert.ToInt32(await _comm.ExecuteNonQueryAsync());
              }
              catch (Exception)
              {
                  throw;
              }
          }
      }
      return _returnValue;
  }
  </code></pre>
  
  <p>in my UI, I call the method like this,</p>
  
  <pre><code>int _recordsAffected = await MyClass.ExecuteNonQueryRawSQLAsync("INSERT....");
  </code></pre>
  
  <p>To test if it's really working, i tried to supply an invalid database server address in the connection string so it keeps on searching until it throws an exception.</p>
  
  <p>While the program is still connecting, the UI freezes. What are the things that are missing in my wrapper? or are there any other needed initializations that I need to do?</p>