protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //全局异常捕获 DispatcherUnhandledException += App_DispatcherUnhandledException; //重复运行判断 if (IsRuned()) { //仅允许运行一次进程 MessageBox.Show("程序已经在运行中了", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); App.Current.Shutdown(); } else { //必须按优先级依次添加 serviceCollection.AddInstance(this); //后台任务 serviceCollection.Add <BackgroundWorkerService>(); //数据统计 serviceCollection.Add <StatisticService>(); //系统资源 serviceCollection.Add <SystemResourcesService>(); //内存缓存 serviceCollection.Add <CacheService>(); //配置文件 serviceCollection.Add <ConfigService>(); //主题 serviceCollection.Add <ThemeService>(); //扩展显示器 serviceCollection.Add <ScreenService>(); //主要 serviceCollection.Add <MainService>(); //托盘 serviceCollection.Add <TrayService>(); //休息 serviceCollection.Add <RestService>(); //声音 serviceCollection.Add <SoundService>(); //快捷键 serviceCollection.Add <KeyboardShortcutsService>(); //预提醒 serviceCollection.Add <PreAlertService>(); //番茄时钟 serviceCollection.Add <TomatoService>(); WindowManager.serviceCollection = serviceCollection; //初始化所有服务 serviceCollection.Initialize(); OnServiceInitialized?.Invoke(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //全局异常捕获 DispatcherUnhandledException += App_DispatcherUnhandledException; //重复运行确认 ReRunCheck(); //必须按优先级依次添加 serviceCollection.AddInstance(this); //数据统计 serviceCollection.Add <StatisticService>(); //系统资源 serviceCollection.Add <SystemResourcesService>(); //内存缓存 serviceCollection.Add <CacheService>(); //配置文件 serviceCollection.Add <ConfigService>(); //主题 serviceCollection.Add <ThemeService>(); //扩展显示器 serviceCollection.Add <ScreenService>(); //主要 serviceCollection.Add <MainService>(); //托盘 serviceCollection.Add <TrayService>(); //休息 serviceCollection.Add <ResetService>(); //声音 serviceCollection.Add <SoundService>(); //快捷键 serviceCollection.Add <KeyboardShortcutsService>(); //预提醒 serviceCollection.Add <PreAlertService>(); WindowManager.serviceCollection = serviceCollection; //初始化所有服务 serviceCollection.Initialize(); OnServiceInitialized?.Invoke(); }