protected override void OnLaunched(LaunchActivatedEventArgs e) { Loc.Init(); #if DEBUG if (Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif if (AppShell == null) { AppShell = new Shell(); Loc.NavigationService.Initialize(); ThreadUI.setDispatcher(NavigationFrame.Dispatcher); AppViewHelper.SetAppView(); Window.Current.Activate(); Loc.Main.AccountManager = new AccountManager(); AppShell.Language = ApplicationLanguages.Languages[0]; AppShell.NavigationFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } } }
protected override async void OnLaunched(LaunchActivatedEventArgs e) { Loc.Init(); #if DEBUG if (Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif await WindowsAppInitializer.InitializeAsync("755097ed-7bf6-41a8-81c4-6d072579a7eb", WindowsCollectors.Metadata | WindowsCollectors.PageView | WindowsCollectors.Session | WindowsCollectors.UnhandledException); if (AppShell == null) { AppShell = new Shell(); App.AppShell.GoToDarkTheme(Loc.Settings.IsApplicationThemeDark); Loc.NavigationService.Initialize(); ThreadUI.setDispatcher(NavigationFrame.Dispatcher); AppViewHelper.SetAppView(); Window.Current.Activate(); Loc.Main.AccountManager = new AccountManager(); AppShell.Language = ApplicationLanguages.Languages[0]; AppShell.NavigationFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } } }
static void Main() { // Windows Forms specific Application.ThreadException += Application_ThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Non-UI specific AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; System.Reflection.Assembly entryassembly = System.Reflection.Assembly.GetEntryAssembly(); if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(entryassembly.Location)).Count() > 1) { MessageBox.Show("Cannot run another instance of this app!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Fix for Telegram.Bot not being able to do something on Windows Server 2008 R2 try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; } catch (Exception ex) { MessageBox.Show("MedocUpdates: Cannot set the security protocol type - TLS/TLS1.1/TLS1.2/SSL3 probably not supported\r\n" + ex.Message); return; } ParsedArgs.SetArgs(Environment.GetCommandLineArgs()); ParsedArgs.PrintArgs(); bool bSettingsWasRestoredFromFile = SessionStorage.Restore(); TelegramChatsStorage.Restore(); Log.Init(); Log.Write(""); Log.Write(String.Format("MedocUpdates: Initializing version {0}...", entryassembly.GetName().Version)); string forcedLang = ParsedArgs.GetArgument("forcelanguage"); if (forcedLang.Trim().Length > 0) { Loc.Init(forcedLang); } else { Loc.Init(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if DEBUG //MUVersion.Init(); //Update update = new Update(MUVersion.latestRelease); //update.UpdateRoutine(); // Crash test zone //throw new ArgumentException("The parameter was invalid"); #endif if (/*true || */ !bSettingsWasRestoredFromFile) { Application.Run(new frmFirstRun()); // Only show if SessionStorage file doesn't exist } Application.Run(new frmMain()); Log.Write("MedocUpdates: Shutting down the application"); SessionStorage.Save(); }