protected override void OnStartup(StartupEventArgs e) { if(e.Args.Contains("WAIT")) Thread.Sleep(5000); SplashScreen appSplash = null; Fap.Foundation.SafeObservableStatic.Dispatcher = System.Windows.Application.Current.Dispatcher; SafeObservingCollectionManager.Start(); this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException); FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); base.OnStartup(e); if (Compose()) { if (e.Args.Length == 1 && e.Args[0] == "WAIT") { //Delay the application starting up, used when restarting. Thread.Sleep(3000); } ApplicationCore core = container.Resolve<ApplicationCore>(); if (!core.CheckSingleInstance()) { //An instance of fap is already running. //If we got a download url then forward onto the runing instance of FAP if (e.Args.Length == 2 && e.Args[0] == "-url") { Model model = new Model(); model.Load(); Client client = new Client(model.LocalNode); AddDownload verb = new AddDownload(); verb.URL = e.Args[1]; if (client.Execute(verb, model.LocalNode)) { //Download sent successfully Shutdown(0); return; } else { //Unsuccessful - Notify user WPFMessageBox.Show("FAP", "Failed to add download via RPC!"); Shutdown(1); return; } } else { //Inform the user they cannot run multiple instances WPFMessageBox.Show("FAP", "An instance of FAP is already running"); Shutdown(1); return; } } string img = GetImage(); appSplash = new SplashScreen(img); appSplash.Show(true); if (core.Load(false)) { core.StartClient(); core.StartGUI(!(e.Args.Contains("STARTUP"))); //Was a url passed on startup? if (e.Args.Length == 2 && e.Args[0] == "-url") { core.AddDownloadUrlWhenConnected(e.Args[1]); } } else { Shutdown(1); } } else { Shutdown(1); } if (null != appSplash) appSplash.Close(TimeSpan.FromSeconds(0)); }