private void Controller_ScannerStatusChanged(object sender, ScannerStatusEvent e) { if (this.InvokeRequired) { var del = new Action(() => Controller_ScannerStatusChanged(sender, e)); this.BeginInvoke(del); } else { switch (e) { case ScannerStatusEvent.Connected: ScannerStatusLabel.Text = "Scanner: Connected"; ScannerStatusLabel.ForeColor = Color.DarkGreen; break; case ScannerStatusEvent.LostConnection: ScannerStatusLabel.Text = "Scanner: Disconnected"; ScannerStatusLabel.ForeColor = Color.DarkRed; break; case ScannerStatusEvent.Error: ScannerStatusLabel.Text = "Scanner: Error!"; ScannerStatusLabel.ForeColor = Color.DarkRed; break; } } }
private void OnScannerStatusChanged(ScannerStatusEvent type) { ScannerStatusChanged?.Invoke(this, type); }