void OnInitMasterEmulatorWorkerDoWork(object sender, DoWorkEventArgs e) { this.Invoke((MethodInvoker) delegate() { log.Add(new StringValue(AppText.StartingUp)); }); masterEmulator = new MasterEmulator(); RegisterEventHandlers(); IEnumerable <string> usbDevices = masterEmulator.EnumerateUsb(); this.Invoke((MethodInvoker) delegate() { PopulateUsbDevComboBox(usbDevices); //string usbSerial; if (masterEmulatorBoardsCount == 0) { MessageBox.Show(AppText.NoDeviceSelected); return; } btnOpenClose.Enabled = true; cboUsbSerial.Enabled = true; }); initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorWorkerDoWork; }
/// <summary> /// Searching for master emulator devices attached to the pc. /// If more than one is connected it will simply return the first in the list. /// </summary> /// <returns>Returns the first master emulator device found.</returns> string FindUsbDevice() { /* The UsbDeviceType argument is used for filtering master emulator device types. */ var devices = masterEmulator.EnumerateUsb(UsbDeviceType.AnyMasterEmulator); if (devices.Count > 0) { return(devices[0]); } else { return(string.Empty); } }
void OnInitMasterEmulatorDoWork(object sender, DoWorkEventArgs e) { this.Dispatcher.BeginInvoke((Action)delegate () { AddLineToLog(AppText.StartingUp); }); masterEmulator = new MasterEmulator(); RegisterEventHandlers(); IEnumerable<string> usbDevices = masterEmulator.EnumerateUsb(); this.Dispatcher.BeginInvoke((Action)delegate () { PopulateUsbDevComboBox(usbDevices); }); initMasterEmulatorWorker.DoWork -= OnInitMasterEmulatorDoWork; }