private void btnDisconnectAuto_Click(object sender, EventArgs e) { try { // if (_loggerTask != null) // _tokenSource.Cancel(); _syncProcessor.Dispose(); _syncProcessor = null; _commandHandler.Kill(); _commandHandler.Dispose(); _commandHandler = null; _tcpCommunication.Dispose(); _tcpCommunication = null; _myFsWatcher.Dispose(); _myFsWatcher = null; SwitchAutoUiState(false); Logger.WriteDisconnectLine(); } catch (Exception ex) { SwitchAutoUiState(false); MessageBox.Show(ex.Message, @"Disconnect"); } }
private void ManageUserLogout() { // Wait for SyncProcessor to be EMPTY first !!! while (_syncProcessor.On) { Task.Delay(100); } _commandHandler.Kill(); _myFsWatcher.Dispose(); Thread.Sleep(100); }