Esempio n. 1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Get this Process
            Process currProcess = Process.GetCurrentProcess();

            // Get Count of All App Instances of Agent
            var agentInstances = Process.GetProcesses().Where(p =>
                                                              p.ProcessName == currProcess.ProcessName &&
                                                              p.SessionId == currProcess.SessionId);

            // For more than one instances
            if (agentInstances.Count() > 1)
            {
                // Close Current App
                App.Current.Shutdown();

                // Bring existing one to front
                WindowHelper.BringWindowToFront();
            }
            else
            {
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
            }
        }