Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }