void OnScanForReceiverClick(object sender, EventArgs e) { view.Log += "Scanning for receivers..." + Environment.NewLine; Thread scannerThread = new Thread(new ThreadStart(() => { NetworkScanner scanner = new NetworkScanner(); scanner.OnOpenPortFound += new EventHandler<OpenPortFoundArgs>(scanner_OnOpenPortFound); IList<string> endpoints = scanner.GetNetworkedDevices(); view.Log += endpoints.Count + " devices found:" + Environment.NewLine; foreach (string endpoint in endpoints) { view.Log += endpoint.ToString() + Environment.NewLine; } })); scannerThread.IsBackground = true; scannerThread.Start(); }