Blacker.MangaScraper.MainWindow.MainWindow_Closing C# (CSharp) Метод

MainWindow_Closing() приватный Метод

private MainWindow_Closing ( object sender, CancelEventArgs cancelEventArgs ) : void
sender object
cancelEventArgs CancelEventArgs
Результат void
        private void MainWindow_Closing(object sender, CancelEventArgs cancelEventArgs)
        {
            var viewModel = this.DataContext as ViewModel.MainWindowViewModel;

            if (viewModel == null)
                return; // this should not happen

            if (viewModel.DownloadManager.HasActiveDownloads)
            {
                if (MessageBox.Show("There are still unfinished downloads. Are you sure you want to quit?",
                                    "Confirm exit",
                                    MessageBoxButton.YesNo,
                                    MessageBoxImage.Question) ==
                    MessageBoxResult.No)
                {
                    cancelEventArgs.Cancel = true;
                }
            }
        }