Beispiel #1
0
        public static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += ExceptionHandler;

            if (SingleInstance <App> .InitializeAsFirstInstance("ElpisInstance"))
            {
                var application = new App();
                application.Init();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #2
0
        public static void Main()
        {
            if (!SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                return;
            }

            App application = new App();

            application.InitializeComponent();
            application.Run();

            SingleInstance <App> .Cleanup();
        }
Beispiel #3
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            MessageBox.Show("WiitarThing is about to crash. Press OK to show the crash message.", "Sorry", MessageBoxButton.OK, MessageBoxImage.Error);

            Exception e = (Exception)args.ExceptionObject;

            SingleInstance <App> .Cleanup();

            Current.Dispatcher.Invoke(new Action(() =>
            {
                var box = new ErrorWindow(e);
                box.ShowDialog();
            }));
        }
Beispiel #4
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                var application = new App();
                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
            //if(args.Length>0) File.WriteAllText(@"err_log.txt", args[0]);
            if (SingleInstance <App> .InitializeAsFirstInstance(appGuid) || (args.Length > 0 && args[0] == @"restarting"))
            {
                var application = new App();
                application.InitializeComponent();
                application.Run();
                SingleInstance <App> .Cleanup();
            }

            //  DesktopNotificationManagerCompat.RegisterAumidAndComServer<MyNotificationActivator>("MTGApro");
        }
Beispiel #6
0
        public static void Main()
        {
            var openAnotherInstance = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

            if (openAnotherInstance || SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var application = new App();
                application.OnReceiveExternalClArgs(Environment.GetCommandLineArgs());
                application.InitializeComponent();
                application.Run();
                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #7
0
        public static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();

            if (args.Length >= 2)
            {
                if (ContainsArg(args, "/quiet"))
                {
                    DetermineInstallMode(true);

                    if (InstallerData.UninstallMode)
                    {
                        Uninstall();
                    }
                    else
                    {
                        foreach (string each in args)
                        {
                            if (each.StartsWith("key=", StringComparison.InvariantCultureIgnoreCase))
                            {
                                InstallerData.ProductKey = each.Substring(5);
                                break;
                            }
                        }

                        Install();
                    }

                    return;
                }
                else if (args[1].ToLowerInvariant() == "/update")
                {
                    InstallerWorker.UpdateRegistry();
                    return;
                }
            }

            if (SingleInstance <App> .InitializeAsFirstInstance(GlobalAssemblyInfo.AssemblyName + " Setup"))
            {
                DisableProcessWindowsGhosting();

                App app = new App();
                app.DispatcherUnhandledException += app_DispatcherUnhandledException;
                app.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #8
0
        public static void Main()
        {
            // Single instance application
            if (!SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                return;
            }
            var app = new App();

            app.InitializeComponent();
            app.Run();

            // Allow single instance code to perform cleanup operations
            SingleInstance <App> .Cleanup();
        }
Beispiel #9
0
        public static void Main()
        {
            if (!SingleInstance <App> .InitializeAsFirstInstance("RecivedCommand"))
            {
                return;
            }

            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(Unique))
     {
         var application = new App();
         application.InitializeComponent();
         application.Run();
         // Allow single instance code to perform cleanup operations
         SingleInstance <App> .Cleanup();
     }
     else
     {
         MessageBox.Show("当前程序已经运行.");
     }
 }
Beispiel #11
0
        public static void Main2()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var application = new App();
                application.InitializeComponent();

                var currentAccent = ThemeManager.Accents.ElementAt(Settings.Default.AccentIndex);
                var currentTheme  = ThemeManager.AppThemes.ElementAt(Settings.Default.BaseIndex);
                ThemeManager.ChangeAppStyle(application, currentAccent, currentTheme);
                application.Run();
                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #12
0
        static void Main()
        {
            var isFirstInstance = HolzShotsApplication.Instance.InitializeAsFirstInstance("HolzShots");

            if (isFirstInstance)
            {
                try
                {
                    HolzShotsApplication.Instance.Run();
                }
                finally
                {
                    SingleInstance.Cleanup();
                }
            }
        }
Beispiel #13
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var application = new App();
                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
            else
            {
                MessageBox.Show("ClockWidget already launched!", "ClockWidget", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Beispiel #14
0
        public static void Main()
        {
            if (!UserSettings.Load().Application.SingleInstance || SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var app = new App();
                app.InitializeComponent();
                app.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
            else
            {
                Environment.Exit(0);
            }
        }
Beispiel #15
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(InstanceUniqueName))
            {
                //SplashScreen splashScreen = null;

                //splashScreen = new SplashScreen("splash_logo.png");
                //splashScreen.Show(false);
                GadrocsWorkshop.Helios.ControlCenter.App app = new GadrocsWorkshop.Helios.ControlCenter.App();
                app.InitializeComponent();
                //Thread.Sleep(1000);
                //splashScreen.Close(TimeSpan.FromMilliseconds(500));
                app.Run();
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #16
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                SplashScreen splashScreen = new SplashScreen("images/logo.png");
                splashScreen.Show(true);

                var application = new App();

                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #17
0
        public static void Main()
        {
            //http://blogs.microsoft.co.il/blogs/arik/archive/2010/05/28/wpf-single-instance-application.aspx

            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                m_currentProcessstatic = Process.GetCurrentProcess();
                var application = new App();

                application.InitializeComponent();
                m_window = new MainWindow();
                application.Run(m_window);

                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #18
0
        public static void Main()
        {
            var openAnotherInstance = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

            if (openAnotherInstance || SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                //Decide here the number of parallel downloads by any Webclient
                System.Net.ServicePointManager.DefaultConnectionLimit = 5;
                var application = new App();
                application.OnReceiveExternalClArgs(Environment.GetCommandLineArgs());
                application.InitializeComponent();
                application.Run();
                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #19
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var app = new App();

                //app.ShutdownMode = ShutdownMode.OnLastWindowClose;

                app.InitializeComponent();

                app.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #20
0
        public static void Main()
        {
            // Only allow a single instance of Statman
            // to run at any given point in time.
            if (!SingleInstance <App> .InitializeAsFirstInstance("Statman_4e29fa"))
            {
                return;
            }

            var s_Application = new App();

            s_Application.InitializeComponent();
            s_Application.Run();

            SingleInstance <App> .Cleanup();
        }
Beispiel #21
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                var application = new App();

                Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

                application.InitializeComponent();

                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #22
0
        private static void SpawnShadowProcess(StartupEventArgs e, string assemblyLocation)
        {
            var shadowAssemblyName = $"{Path.GetFileNameWithoutExtension(assemblyLocation)}.shadow.exe";
            var shadowPath         = Path.Combine(Path.GetTempPath(), "FBDashboard", shadowAssemblyName);

            try
            {
                if (File.Exists(shadowPath))
                {
                    File.Delete(shadowPath);
                }

                Debug.Assert(assemblyLocation != null, "assemblyLocation != null");
                Directory.CreateDirectory(Path.GetDirectoryName(shadowPath));
                File.Copy(assemblyLocation, shadowPath);

                // Copy FBuild folder with worker if exists.
                var workerFolder       = Path.Combine(Path.GetDirectoryName(assemblyLocation), "FBuild");
                var workerTargetFolder = Path.Combine(Path.GetDirectoryName(shadowPath), "FBuild");
                if (Directory.Exists(workerFolder))
                {
                    Directory.CreateDirectory(workerTargetFolder);
                    // Copy all worker files.
                    foreach (string newPath in Directory.GetFiles(workerFolder, "*.*", SearchOption.TopDirectoryOnly))
                    {
                        File.Copy(newPath, newPath.Replace(workerFolder, workerTargetFolder), true);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                // may be already running
            }
            catch (IOException)
            {
                // may be already running
            }

            AppBootstrapper.CreateShadowContext(shadowPath);
            SingleInstance <App> .Cleanup();

            Process.Start(new ProcessStartInfo
            {
                FileName  = shadowPath,
                Arguments = string.Join(" ", e.Args.Concat(new[] { AppArguments.ShadowProc }))
            });
        }
Beispiel #23
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance("{35BBF621-4276-48A8-AEEB-71011A44C476}"))
            {
                var application = new App();

                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
            else
            {
                MessageBox.Show($"{Assembly.GetEntryAssembly().GetName().Name} is already running.");
            }
        }
Beispiel #24
0
        public static void Main()
        {
            var directoryName = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            if (directoryName != null && Directory.GetCurrentDirectory() != directoryName)
            {
                Directory.SetCurrentDirectory(directoryName);
            }

            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                new App().Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #25
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(ApplicationID))
            {
#if !DEBUG
                SplashScreen splash = new SplashScreen("resources\\splashScreen.png");
                splash.Show(true, true);
#endif

                var application = new App();

                application.InitializeComponent();
                application.Run();

                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #26
0
        public static void Main()
        {
            Assembly assembly  = Assembly.GetExecutingAssembly();
            var      attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
            var      guid      = attribute.Value;

            if (SingleInstance <App> .InitializeAsFirstInstance(guid))
            {
                var application = new App();

                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #27
0
        public static void Main()
        {
            AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Determining if another instance of {AppInfo.BaseAppInfo.AppName} is running.");
            if (SingleInstance <App> .InitializeAsFirstInstance("LogViewer_sag65s4dfjkdlsjk45jk34klj23j4jk53456fy3u"))
            {
                AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Determined that no other application instances are running. Continuing execution.");
                new SplashScreen("SplashScreen1.png").Show(true);

                //Upgrade user settings
                try
                {
                    if (Settings.Default.UpgradeSettings)
                    {
                        AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Upgrading user settings.");
                        Settings.Default.Upgrade();
                        Settings.Default.UpgradeSettings = false;
                        Settings.Default.Save();
                        AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"User settings successfully upgraded.");
                    }

                    if (Settings.Default.UpgradeDatabaseSettings2)
                    {
                        AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Upgrading database settings.");
                        SettingsService.UpgradeDatabaseSettings();
                        AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Database settings successfully upgraded.");
                    }
                }
                catch (Exception ex)
                {
                    AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Failed to upgrade user or database settings. Error message: {ex.Message}", LogMessageType.Error);
                }

                var application = new App();
                application.InitializeComponent();
                application.Run();

                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
            else
            {
                AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Determined that another application instance is running. Forwarding command parameters to existing instance and terminating.");
                AppInfo.BaseAppInfo.Log.Dispose();
            }
        }
Beispiel #28
0
        public static void Main()
        {
            if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
            {
                string [] args = Environment.GetCommandLineArgs();
                if (args.Count() > 1 && args[1].Equals("-min"))
                {
                    Settings.Default.Do_minimize = true;
                }
                var application = new App();
                application.InitializeComponent();
                application.Run();


                // Allow single instance code to perform cleanup operations
                SingleInstance <App> .Cleanup();
            }
        }
Beispiel #29
0
 public static void Main()
 {
     if (SingleInstance <Views.App> .InitializeAsFirstInstance("org.eduvpn.app"))
     {
         try
         {
             // First instance
             var application = new App();
             application.InitializeComponent();
             application.Run();
         }
         finally
         {
             // Allow single instance code to perform cleanup operations.
             SingleInstance <Views.App> .Cleanup();
         }
     }
 }
Beispiel #30
0
        static void Main(string[] args)
        {
            if (args.Length != 8)
            {
                return;
            }
            if (SingleInstance <App> .InitializeAsFirstInstance(AppId))
            {
                var win = new MainWindow();
                var vm  = new MainWindowViewModel(args, win.Close);
                win.DataContext = vm;

                var application = new App();
                application.InitializeComponent();
                application.Run(win);
                SingleInstance <App> .Cleanup();
            }
        }