public object GetSqlConnString(RubrikkUser user, RubrikkDb db) { // deadlock if called from threadpool, // works fine on UI thread, works fine from console main return(Task.Run(() => GetSqlConnStringAsync(user, db)).Result); }
private async Task <object> GetSqlConnStringAsync(RubrikkUser user, RubrikkDb db) { SqlConnection conn = new SqlConnection(@"Data Source=.\INST; Integrated Security=SSPI"); await conn.OpenAsync(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT 'test'"; return(cmd.ExecuteScalarAsync()); }