I find that my C# app UI hangs when calling an async method, I cannot figure out why.
private async void selectCSVFileButton_Click(object sender, EventArgs e)
{
...
var results = await ntz.getProductNames();
...
}
...
public async Task<List<string[]>> getProductNames()
{
string fmt = "DRIVER={{NetezzaSQL}};SERVER={0};PORT={1};DATABASE={2};UID={3};PWD={4};";
ntz = new OdbcConnection(string.Format(fmt, server, port, db, user, password));
await ntz.OpenAsync();
qry = "SELECT * FROM ak_db_1 WHERE prod_name_desc='Unknown'";
OdbcCommand cmd = ntz.CreateCommand();
cmd.CommandTimeout = 600;
cmd.CommandText = qry;
await cmd.ExecuteNonQueryAsync();
...
}
My application hangs completely (UI unresponsive) until the cmd.ExecuteNonQueryAsync completes. Any ideas?