private void disconnect() { //this is not so pretty, but we want to clear away any junk //that would cause a connect to fail later do { _commsPort.ReadExisting(); Thread.Sleep(100); } while (_commsPort.BytesToRead > 0); _appState.State = State.NotConnected; _commsPort.EnsureClosed(); OnCompeted(); }
protected void OnDisconnectActionActivated(object sender, EventArgs e) { // TODO: This code is duplicated from WinForms.StripCommands.DisconnectStripCommand // TODO: Check for background tasks that are using the serial port //this is not so pretty, but we want to clear away any junk //that would cause a connect to fail later while (commsPort.BytesToRead > 0) { commsPort.ReadExisting(); Thread.Sleep(100); } appState.State = NXTCamView.Core.State.NotConnected; commsPort.EnsureClosed(); }