Exemplo n.º 1
0
        public App()
        {
            if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "Updater001.exe"))
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.UseShellExecute  = true;
                startInfo.WorkingDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
                startInfo.FileName         = "powershell.exe";
                startInfo.Arguments        = "-WindowStyle hidden start-sleep 5;Remove-Item -Path .\\Updater.exe; Move-Item -Path .\\Updater001.exe -Destination .\\Updater.exe;";
                Process.Start(startInfo);
            }

            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

            uniqueMutex = new Mutex(true, uniqueAppGuid, out bool gotMutex);
            GC.KeepAlive(App.uniqueMutex);

            if (SingleInstance.IsFirstInstance(uniqueAppGuid, true))
            {
                SingleInstance.OnSecondInstanceStarted += SingleInstance_OnSecondInstanceStarted;
            }
            else
            {
                // second instance so notify first instance
                SingleInstance.NotifyFirstInstance(uniqueAppGuid);
            }

            if (!gotMutex)
            {
                App.Current.Shutdown(); // only one instance of the app opened at a time so shutdown
                return;
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Trace(LoggingTag, "SwerveToolsTray starting...");
            //
            SingleInstance singleInstance = new SingleInstance(TrayUniquifier);

            if (singleInstance.IsFirstInstance())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new TrayApplicationContext());
            }
            else
            {
                Trace(LoggingTag, "not first instance");
            }
            //
            Trace(LoggingTag, "...exiting SwerveToolsTray");
        }
Exemplo n.º 3
0
        public App()
        {
            uniqueMutex = new Mutex(true, uniqueAppGuid, out bool gotMutex);
            GC.KeepAlive(App.uniqueMutex);

            if (SingleInstance.IsFirstInstance(uniqueAppGuid, true))
            {
                SingleInstance.OnSecondInstanceStarted += SingleInstance_OnSecondInstanceStarted;
            }
            else
            {
                // second instance so notify first instance
                SingleInstance.NotifyFirstInstance(uniqueAppGuid);
            }

            if (!gotMutex)
            {
                App.Current.Shutdown(); // only one instance of the app opened at a time so shutdown
                return;
            }
        }