示例#1
0
        static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                //PPMProjectPlanList form = new PPMProjectPlanList();
                //Application.Run(form);
                //return;

                var process = Process.GetCurrentProcess();
                onlyOne = new Mutex(true, process.ProcessName);
                if (!onlyOne.WaitOne(0, false))
                {
                    MessageBox.Show("BugTrace已经启动");
                    return;
                }

                LoginForm loginForm = new LoginForm();
                if (loginForm.ShowDialog() == DialogResult.OK)
                {
                    MainForm mainForm = new MainForm();
                    SingleInstanceApplicationWrapper wrapper = new SingleInstanceApplicationWrapper(mainForm);
                    wrapper.Run(args);
                }
                else
                {
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "系统登陆", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Application.Exit();
            }

            #region Toolkit运行单例程序
            //if (!JAJ.Toolkit.Program.AlreadyRuning)
            //{
            //    Application.Run(new Form1());
            //    JAJ.Toolkit.Program.ReleaseMutex();
            //}
            //else
            //{
            //    String msg;
            //    if (!JAJ.Toolkit.Program.ActivateAlreadyRuning(out msg))
            //    {
            //        MessageBox.Show(msg);
            //    }
            //}
            #endregion
        }
示例#2
0
        public static void Main(string[] args)
        {
            SingleInstanceApplicationWrapper wrapper = new SingleInstanceApplicationWrapper();

            wrapper.Run(args);
        }
        /// <summary>
        /// Starts the single instance application wrapper
        /// </summary>
        /// <param name="window">The Window which is to be started. This can be null</param>
        /// <returns>The return code returned from the WPF Application instance</returns>
        private int Start(Window window)
        {
            var wrapper = new SingleInstanceApplicationWrapper(this, IsSingleInstance) { Window = window };

            // Although an empty array of string can be given to the application wrapper, if done so then subsequent
            // instances will not be provided command line arguments in the
            // Microsoft.VisualBasic.ApplicationServices.StartupEventArgs argument
            wrapper.Run(Environment.GetCommandLineArgs());
            return wrapper.ReturnCode;
        }