override protected void OnStart() { appViewModel = new PeerCastAppViewModel(Application); versionChecker = new PeerCastStation.UI.Updater(); notifyIconThread = new Thread(() => { notifyIconManager = new NotifyIconManager(appViewModel, this); versionChecker.NewVersionFound += (sender, e) => { notifyIconManager.NotifyNewVersions(e.VersionDescriptions); }; notifyIconManager.Run(); }); notifyIconThread.SetApartmentState(ApartmentState.STA); notifyIconThread.Start(); versionCheckTimer = new Timer(OnVersionCheckTimer, null, 1000, 1000 * 3600 * 24); mainThread = new Thread(() => { var app = new Application(); var settings = Application.Settings.Get <WPFSettings>(); mainWindow = new MainWindow(appViewModel); if (settings.ShowWindowOnStartup) { mainWindow.Show(); } app.Run(); }); mainThread.Name = "WPF UI Thread"; mainThread.SetApartmentState(ApartmentState.STA); mainThread.Start(); Application.MessageNotified += OnMessageNotified; }
override protected void OnStart() { appViewModel = new PeerCastAppViewModel(Application); versionChecker = new PeerCastStation.UI.Updater(); notifyIconThread = new Thread(() => { notifyIconManager = new NotifyIconManager(appViewModel, this); versionChecker.NewVersionFound += (sender, e) => { notifyIconManager.NotifyNewVersions(e.VersionDescriptions); }; notifyIconManager.Run(); }); notifyIconThread.SetApartmentState(ApartmentState.STA); notifyIconThread.Start(); versionCheckTimer = new Timer(OnVersionCheckTimer, null, 1000, 1000*7200); mainThread = new Thread(() => { var app = new Application(); var settings = Application.Settings.Get<WPFSettings>(); mainWindow = new MainWindow(appViewModel); if (settings.ShowWindowOnStartup) mainWindow.Show(); app.Run(); }); mainThread.Name = "WPF UI Thread"; mainThread.SetApartmentState(ApartmentState.STA); mainThread.Start(); }
protected override void OnStart() { notifyIconThread = new Thread(() => { #if !DEBUG try #endif { notifyIconManager = new NotifyIconManager(Application.PeerCast); notifyIconManager.CheckVersionClicked += (sender, e) => versionChecker.CheckVersion(); notifyIconManager.QuitClicked += (sender, e) => Application.Stop(); notifyIconManager.ShowWindowClicked += (sender, e) => { if (mainWindow!=null) { mainWindow.Dispatcher.Invoke(new Action(() => { mainWindow.Show(); if (mainWindow.WindowState==WindowState.Minimized) { mainWindow.WindowState = WindowState.Normal; } mainWindow.Activate(); })); } }; versionChecker = new AppCastReader( new Uri(Settings.Default.UpdateURL, UriKind.Absolute), Settings.Default.CurrentVersion); versionChecker.NewVersionFound += (sender, e) => { notifyIconManager.NewVersionInfo = e.VersionDescription; }; versionChecker.CheckVersion(); notifyIconManager.Run(); } #if !DEBUG catch (Exception e) { logger.Fatal("Unhandled exception"); logger.Fatal(e); throw; } #endif }); notifyIconThread.SetApartmentState(ApartmentState.STA); notifyIconThread.Start(); mainThread = new Thread(() => { #if !DEBUG try #endif { var app = new Application(); viewModel = new MainViewModel(Application); var settings = Application.Settings.Get<WPFSettings>(); mainWindow = new MainWindow(viewModel); if (settings.ShowWindowOnStartup) mainWindow.Show(); app.Run(); viewModel.Dispose(); } #if !DEBUG catch (Exception e) { logger.Fatal("Unhandled exception"); logger.Fatal(e); throw; } #endif }); mainThread.Name = "WPF UI Thread"; mainThread.SetApartmentState(ApartmentState.STA); mainThread.Start(); }