private void PushButton_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Command-Windows will rapidly open and close. This is Blender" + " exporting the models in the background. Please be patient!"); var exporter = new ModelExporter(BlenderPathBox.Text, System.IO.Path.Combine(GamePathBox.Text, "Graphics"), System.IO.Path.Combine(GamePathBox.Text, "Export")); PushButton.IsEnabled = false; PushButton.Content = "Exporting... Do Not Close Window"; CancelButton.IsEnabled = false; Task.Run(() => exporter.ExportAll()) .ContinueWith(delegate { Dispatcher.Invoke(delegate { if (exporter.ExceptionObject != null) { MessageBox.Show("Error extracting, check your paths and try again. " + exporter.ExceptionObject.Message); } else { MessageBox.Show("Success! The models were sent to: " + GamePathBox.Text); (Parent as Window).Close(); } }); }); }