static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) { Exception e = (Exception)args.ExceptionObject; SingleInstance <App> .Cleanup(); Current.Dispatcher.Invoke(new Action(() => { var box = new ErrorWindow(e); box.ShowDialog(); })); }
public static void Main() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (SingleInstance <App> .InitializeAsFirstInstance("TachographReader")) { var app = new App(); app.InitializeComponent(); app.Boot(); app.Run(); } }
public static void Main() { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { using (var application = new App()) { application.InitializeComponent(); application.Run(); } } }
private static void StartUp() { if (SingleInstance <SimpleMusicPlayerApplication.App> .InitializeAsFirstInstance("18980929-1342-4467-bc3d-37b0d13fa938")) { var application = new SimpleMusicPlayerApplication.App(); application.Init(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <SimpleMusicPlayerApplication.App> .Cleanup(); } }
protected override void OnExit(ExitEventArgs e) { Scheduler?.Stop(); ProxyServer.Stop(); SingleInstance.Stop(); CentralHandler?.Dispose(); LogTo.Info("Application exit"); Kernel?.Dispose(); base.OnExit(e); }
public static void Main() { if (SingleInstance <App> .InitializeAsFirstInstance("888666555")) { var application = new App(); application.InitializeComponent(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public App() { if (SingleInstance.InitializeAsFirstInstance(this)) { // ok } else { // instance exists, exit. Shutdown(1); } }
private static void Main() { if (SingleInstance <App> .InitializeAsFirstInstance("{EB9E0C35-8DC5-459D-80C2-93DCE0036C91}")) { var application = new App(); application.InitializeComponent(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public static void Main() { if (SingleInstance <App> .InitializeAsFirstInstance("AdvancedJumpList")) { var application = new App(); application.Init(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
private void App_OnStartup(object sender, StartupEventArgs e) { Directory.SetCurrentDirectory(Path.GetDirectoryName(Utils.Utils.GetExecutablePath())); if (e.Args.Contains(Constants.ParameterSetAutoRun)) { if (!AutoStartup.Switch()) { Environment.Exit(1); } Current.Shutdown(); return; } var identifier = $@"Global\{UpdateChecker.Name}_{Directory.GetCurrentDirectory().GetDeterministicHashCode()}"; var singleInstance = new SingleInstance(identifier); if (!singleInstance.IsFirstInstance) { singleInstance.PassArgumentsToFirstInstance(e.Args.Append(Constants.ParameterShow)); Current.Shutdown(); return; } singleInstance.ArgumentsReceived += SingleInstance_ArgumentsReceived; singleInstance.ListenForArgumentsFromSuccessiveInstances(); GlobalConfig.Load(); Current.DispatcherUnhandledException += (o, args) => { if (Interlocked.Increment(ref _exited) == 1) { MessageBox.Show($@"未捕获异常:{args.Exception}", UpdateChecker.Name, MessageBoxButton.OK, MessageBoxImage.Error); Log.ForceLog(args.Exception.ToString()); GlobalConfig.Save(); singleInstance.Dispose(); Current.Shutdown(); } }; Current.Exit += (o, args) => { Utils.Utils.KillFFmpeg(); singleInstance.Dispose(); GlobalConfig.Save(); }; CheckUpdateAsync(); MainWindow = new MainWindow(); if (!e.Args.Contains(Constants.ParameterSilent)) { MainWindow.Show(); } }
static void Main(string[] args) { if (!SingleInstance.InitializeAsFirstInstance(SignalExternalCommandLineArgs)) { Environment.Exit(0); } Context.Startup(); Context.ProcessingQueueEmpty += Shutdown; Context.Log += OnLog; Context.ProcessingProcessChanged += OnProcessingProcessChanged; Context.ProcessingProgressChanged += OnProcessingProgressChanged; bool show_help = false; bool clean_cache = false; var p = new OptionSet() { { "h|help", "show this message and exit.", v => show_help = (v != null) }, { "clean", "clean cache.", v => clean_cache = true }, }; var extra = p.Parse(args); if (show_help) { ShowHelp(p); Shutdown(); } else { if (clean_cache) { Cache.Clear(); } c_event = new AutoResetEvent(false); if (extra.Count > 0) { HandleArgs(extra); c_event.WaitOne(); } else { Shutdown(); } } }
public CodeOnlyPageView() { InitializeComponent(); // Singleton using the default constructor. var singleton = new SingleInstance<Cargo>(); // Singleton using factory method. var singleton2 = new SingleInstance<Cargo>(FactoryMethod); Debug.Assert(singleton.Instance != null); Debug.Assert(singleton2.Instance != null); }
public static void Main() { // Check that only one instance of the application is running if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { var application = new App(); application.InitializeComponent(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public static void Main() { // force english exception message for better github issue Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { using (var application = new App()) { application.InitializeComponent(); application.Run(); } } }
protected override void OnStartup(StartupEventArgs e) { _singleInstance = new SingleInstance(Guid.Parse("{ff1b2b33-9a71-4e8d-9ace-dec72894c4d7}")); if (!_singleInstance.StartApplication()) { _singleInstance.NotifyFirstInstance(e.Args); Environment.Exit(0); return; } _singleInstance.NewInstance += SingleInstance_NewInstance; base.OnStartup(e); }
public CodeOnlyPageView() { InitializeComponent(); // Singleton using the default constructor. var singleton = new SingleInstance <Cargo>(); // Singleton using factory method. var singleton2 = new SingleInstance <Cargo>(FactoryMethod); Debug.Assert(singleton.Instance != null); Debug.Assert(singleton2.Instance != null); }
protected override void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var l = _container.Resolve <ILogService>(); var n = _container.Resolve <IUserNotifyer>(); n.NotifyError($"Unexpected crash occured: {e.Exception.Message}"); l.Fatal($"Unexpected crash occured: {e.Exception.Message}", e.Exception); e.Handled = true; base.OnUnhandledException(sender, e); SingleInstance.ReleaseMutex(); }
public static void Main(String[] args) { if (Keyboard.IsKeyDown(Key.LeftShift) || SingleInstance <App> .InitializeAsFirstInstance(Unique) || args.Length < 1) { var application = new App(); application.InitializeComponent(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ChangeTheme(); if (SingleInstance <App> .InitializeAsFirstInstance(guid)) { new Bootstrapper(); } else { Shutdown(); } }
static void Main(string[] args) { bool isRestart = args.Length > 0 && args[0] == "Restart"; if (!isRestart && SingleInstance.IsRunning()) { return; } Updater.PeriodicUpdate(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
/// <summary> /// 当前应用程序的重启 /// </summary> public void Restart() { GlobalData.Save(); ProcessModule mainModule = Process.GetCurrentProcess().MainModule; if (mainModule != null) { SingleInstance <App> .Cleanup(); Process.Start(mainModule.FileName); Application.Current.Shutdown(); } }
public static void Main() { if (!SingleInstance <App> .InitializeAsFirstInstance("DeltaEngine.Editor")) { return; } MakeSureEditorDirectoryUsed(); var application = new App(); application.InitializeComponent(); application.Run(); SingleInstance <App> .Cleanup(); }
public static void Main() { if (SingleInstance <App> .InitializeAsFirstInstance(AppID)) { var application = new App(); application.splash = new SplashScreen("Assets/zenova_splash.png"); application.splash.Show(false); application.InitializeComponent(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public static void Main(params string[] args) { if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { var application = new App(); application.InitializeComponent(); application.Parameters = args.ToList(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public static void Main() { RegisterAppDomainExceptions(); if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { using (var application = new App()) { application.InitializeComponent(); application.Run(); } } }
static void Main(string[] args) { if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { var application = new App(); application.InitializeComponent(); application.Run(); SingleInstance <App> .Cleanup(); } return; }
public static void Main() { if (SingleInstance <App> .InitializeAsFirstInstance("Simplane")) { App application = new App(); application.Init(); application.Run(); // Allow single instance code to perform cleanup operations SingleInstance <App> .Cleanup(); } }
public static void Main() { // Ensure there can be only one instance of the application if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { var application = new App(); application.InitializeComponent(); application.Run(); SingleInstance <App> .Cleanup(); } }
public static void Main() { CommonFunc.IntialUniqleString(); if (SingleInstance <App> .InitializeAsFirstInstance(GlobalVar._uniqueStr)) { var application = new App(); application.InitializeComponent(); application.Run(); SingleInstance <App> .Cleanup(); } }
public static void Main(string[] args) { if (SingleInstance <App> .InitializeAsFirstInstance(Unique)) { int.TryParse(args[0], out _powerToysPid); using (var application = new App()) { application.InitializeComponent(); application.Run(); } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (SingleInstance.IsRunning()) { return; } AppString.LoadStrings(); Updater.PeriodicUpdate(); XmlDicHelper.ReloadDics(); Application.Run(new MainForm()); }
private static void Main() { string applicationIdentifier = "NeoRhythm_75B462B3-689A-4bee-BCA9-47A0842C3C2C"; using (SingleInstance instance = new SingleInstance(applicationIdentifier)) { if (instance.AlreadyRunning) { instance.TryActivatePreviousInstance(applicationIdentifier); } else { MainForm mainForm = new MainForm(); mainForm.Text = applicationIdentifier; try { Application.Run(mainForm); } catch (Exception) { } } } }
static void Main() { string windowCaption = "C71F25F8-ECFF-3d90-92DF-D6D977CDDA72"; // IMPORTANT -> create a new guid and insert it here using (SingleInstance instance = new SingleInstance(windowCaption)) { if (instance.AlreadyRunning) { instance.TryActivatePreviousInstance(windowCaption); } else { MainView mainView = new MainView(); mainView.Text = windowCaption; mainView.ShowDialog(); } } }
public Window1(SingleInstance.SingleInstanceApplicationWrapper container) { ApplicationParent = container; InitializeComponent(); Show(); }