示例#1
0
文件: Program.cs 项目: slawer/sgt
        static void Main()
        {
            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

                mutex = new Mutex(true, identifier, out isNotRunning);
                if (isNotRunning)
                {
                    app = SgtApplication.CreateInstance();
                    if (app != null)
                    {
                        app.Load();
                        app.Commutator.DeSerialize();

                        app.Connect();

                        System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

                        System.Windows.Forms.Application.EnableVisualStyles();
                        System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

                        System.Windows.Forms.Application.Run(new mainForm());
                    }
                }
                else
                    MessageBox.Show("Приложение уже запущено", "Информация",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteToLog(null, new ErrorArgs(ex.Message, ErrorType.Unknown));
            }
        }
示例#2
0
文件: Program.cs 项目: slawer/sgt
        static void Main()
        {
            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

                mutex = new Mutex(true, identifier, out isNotRunning);
                if (isNotRunning)
                {
                    app = SgtApplication.CreateInstance();
                    if (app != null)
                    {
                        app.Load();
                        app.Commutator.DeSerialize();

                        app.Connect();

                        System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

                        System.Windows.Forms.Application.EnableVisualStyles();
                        System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

                        System.Windows.Forms.Application.Run(new mainForm());
                    }
                }
                else
                {
                    MessageBox.Show("Приложение уже запущено", "Информация",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteToLog(null, new ErrorArgs(ex.Message, ErrorType.Unknown));
            }
        }