source: trunk/CrypStartup/App.xaml.cs @ 3067

Last change on this file since 3067 was 3067, checked in by Sven Rech, 11 years ago
  • integrated unhandled exception dialog into CrypStartup (refs #238)
  • new exes
File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Configuration;
4using System.Data;
5using System.Linq;
6using System.Threading;
7using System.Windows;
8using System.Windows.Forms;
9using System.Windows.Threading;
10using Cryptool.Core;
11using Application = System.Windows.Application;
12
13namespace CrypStartup
14{
15    /// <summary>
16    /// Interaction logic for App.xaml
17    /// </summary>
18    public partial class App : Application
19    {
20        public App()
21        {
22            System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
23            System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
24            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
25        }
26
27        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
28        {
29            Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
30            {
31                UnhandledExceptionDialog.ShowModalDialog((Exception)e.ExceptionObject);
32            }, null);
33        }
34
35
36
37        private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
38        {
39            UnhandledExceptionDialog.ShowModalDialog(e.Exception);
40        }
41
42        private void Application_Startup(object sender, StartupEventArgs e)
43        {
44            long x, y;
45            x = DateTime.Now.Ticks;
46            Cryptool.CrypWin.MainWindow wnd = new Cryptool.CrypWin.MainWindow();
47            try
48            {
49                wnd.Show();
50            }
51            catch (Exception)
52            {
53                //This window has already been closed
54            }
55            y = DateTime.Now.Ticks - x;
56            Console.WriteLine(y.ToString());
57        }
58    }
59}
Note: See TracBrowser for help on using the repository browser.