private void RefreshComPorts() { cbComPort.Items.Clear(); foreach (var port in ComPortManager.GetAvaliableComPorts()) { cbComPort.Items.Add(port); } if (cbComPort.Items.Count > 0) { cbComPort.SelectedIndex = cbComPort.Items.Count - 1; } }
private async Task RefreshPorts() { listBoxPorts.Enabled = false; buttonRefresh.Enabled = false; var ports = await ComPortManager.GetAllPortsAsync(); listBoxPorts.Invoke(new Action( () => { listBoxPorts.Items.Clear(); listBoxPorts.Items.AddRange(ports.ToArray()); listBoxPorts.Enabled = true; buttonRefresh.Enabled = true; })); }
protected override void OnStart(string[] args) { _log = new EventLogger("RFID"); _log.WriteDebugLine("Service", "Started"); _connection = new RfidConnection(_log); _connection.RfidReceived += Connection_RfidReceived; _connection.ReaderStateChanged += Connection_ReaderStateChanged; _connection.Start(); _pipeServer = new PipeConnectionsManager(_log); _pipeServer.OnReaderUpdateRequest += PipeServer_OnReaderUpdateRequest; _pipeServer.Start(); _comPortManager = new ComPortManager(_log); _comPortManager.RfidReceived += Connection_RfidReceived; _comPortManager.ReaderStateChanged += Connection_ReaderStateChanged; _comPortManager.Start(); }