+ 3

C# How to use async

Hi :) (sorry, english) I'm new about async/await and I don't know, if I do it well. Can you check it? please. I have to download something from database. private async Task<string[]> GetPrioritiesAsync() => await Task.Factory.StartNew(() => Get(MethodBase.GetCurrentMethod().Name)); private async Task<string[]> GetEquipmentAsync() => await Task.Factory.StartNew(() => Get(MethodBase.GetCurrentMethod().Name)); private string[] Get(string queryName) { var listOfValue = new List<string>(); using (var com = new MySqlCommand(Setting.GetQuery(queryName))) if (com.ExecuteNonQuery() > 0) using (var reader = com.ExecuteReader()) while (reader.HasRows) listOfValue.Add(reader.GetString("prio")); return listOfValue.ToArray(); }

20th Dec 2017, 9:16 PM
Kacper Piotrowski
Kacper Piotrowski - avatar
1 Réponse