using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using BirdyFlash.Lib; using MaterialSkin; using MaterialSkin.Controls; namespace BirdyFlash { partial class ScanningPagersDialog : MaterialForm { public ScanningPagersDialog() { InitializeComponent(); } List portList = new List(); int resultCount = 0; private void ScanningPagersDialog_Load(object sender, EventArgs e) { MaterialSkinManager.Instance.AddFormToManage(this); } internal void Setup(List portList) { this.portList = portList; } private async void TestPort(string portName) { using (var comm = new Lib.BirdyComm()) { comm.SetPort(CommPort.From(portName)); try { var data = await comm.TryGetDeviceInfo(); Console.WriteLine(data.deviceSerial); this.Invoke(new Action(() => { txtLog.AppendText(string.Format("{0} type {1} serial {2}\n", portName, data.model, data.deviceSerial)); })); } catch (Exception ex) { Console.WriteLine(ex.ToString()); this.Invoke(new Action(() => { txtLog.AppendText(string.Format("{0} timeout\n", portName)); })); } } } private void ScanningPagersDialog_Shown(object sender, EventArgs e) { /*foreach(string portName in this.portList) { Task.Run(() => TestPort(portName)); }*/ } } }