Exemple #1
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnStartup(StartupEventArgs e)
        {
            this.DispatcherUnhandledException          += App_DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            System.Threading.Tasks.TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

            //设置当前程序集
            this.ShutdownMode = ShutdownMode.OnMainWindowClose;
            //初始化当前程序集样式
            ThemeSwitcher.SetTheme(ThemeEnum.METRO);
            //初始化程序
            PluginHelper.LoadApplication();
            //创建入口程序对象

            var launcher = PluginHelper.CreateInstanceByKey("Launcher");

            if (launcher != null)
            {
                await Task.Factory.StartNew(() =>
                {
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        launcher.Run();
                    }));
                });

                base.OnStartup(e);
                return;
            }

            System.Environment.Exit(System.Environment.ExitCode);
        }