Trying to get a list of COM
ports in the UWP
. I write the list of ports to the variable dis
, but it immediately goes to the next line, although there is await
. How to make await
wait for all ports to return correctly?
try { string devSel = SerialDevice.GetDeviceSelector(); var dis = await DeviceInformation.FindAllAsync(devSel); for (int i = 0; i < dis.Count; i++) { lst.Add(dis[i]); } serialPort = await SerialDevice.FromIdAsync(lst[0].Id); } catch (Exception ex) { }
serialPort
, then you actually have a synchronous code. - MonkGetResults
, plus typicallyawait
asynchronous before using the variable in which it is clogged, i.e. before any operation with yourserialPort
variable. - Monk