private void StartOnClick(object sender, RoutedEventArgs e) { xmlPath = importFilePath.Text; xmlWorker = new BackgroundWorker(); xmlWorker.WorkerSupportsCancellation = true; xmlWorker.DoWork += new DoWorkEventHandler(DoWork); xmlWorker.RunWorkerCompleted += (s, _e) => { isWorking = false; if (!_e.Cancelled && MessageBox.Show("Importing finised!", "Status", MessageBoxButton.OK, MessageBoxImage.Information) == MessageBoxResult.OK) { this.DialogResult = true; } else { importStart.IsEnabled = true; } }; if (File.Exists(MylistDB.dbPath)) { if (MessageBox.Show("A mylist database file already exists.\nDo you wish to overwrite it?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { m_myList.Close(); try { File.Move(MylistDB.dbPath, MylistDB.dbPath + ".bak"); isBackup = true; } catch (IOException) { } } else { return; } } xmlWorker.RunWorkerAsync(); isWorking = true; importStart.IsEnabled = false; }
private void OnClose(object sender, System.ComponentModel.CancelEventArgs e) { if (ConfigFile.Read("mpcClose").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked) { m_mpcAPI.CloseMPC(); } m_myList.Close(); m_aniDBAPI.Logout(); m_notifyIcon.Dispose(); m_notifyIcon = null; }