C# How to use async | Sololearn: Learn to code for FREE!

+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(); }

12/20/2017 9:16:23 PM

Kacper Piotrowski

1 Answer

New Answer

+4

Look! it's here ↓↓↓ :) https://docs.microsoft.com/en-us/dotnet/csharp/async https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/