private void MainWindow_OnClosed(object sender, CancelEventArgs e) { if (!QuartzHelper.GetInstanceScheduler().IsStarted) { QuartzHelper.GetInstanceScheduler().Shutdown(); return; } var result = MessageBox.Show("若后台方案正在执行,方案将被取消,是否退出?", "", MessageBoxButton.YesNo, MessageBoxImage.Information); if (result == MessageBoxResult.Yes) { QuartzHelper.GetInstanceScheduler().Shutdown(); return; } e.Cancel = true; }