예제 #1
0
        static void Main()
        {
            Application.SetCompatibleTextRenderingDefault(false);
            //设置应用程序处理异常方式:ThreadException处理
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.EnableVisualStyles();
            try
            {
                string mName = Process.GetCurrentProcess().MainModule.ModuleName;
                string pName = Path.GetFileNameWithoutExtension(mName);
                Process[] pro = Process.GetProcessesByName(pName);
                if (pro.Length > 1)
                {
                    MessageBox.Show("程序已经在运行,无需重复运行。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.ExitThread();
                    return;
                }
                ThemeResolutionService.LoadPackageResource("OSUplayer.Res.Light.tssp");
                ThemeResolutionService.ApplicationThemeName = "Light";
                Un4seen.Bass.BassNet.Registration("*****@*****.**", "2X280331512622");
                Un4seen.Bass.Bass.BASS_Init(-1, 44100, Un4seen.Bass.BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                Main mainwindow = new Main();
                mainwindow.Show();
                while (mainwindow.Created)
                {
                    Application.DoEvents();
                    Core.Render();
                    Thread.Sleep(5);
                }

                //   Application.Run(new Main());
            }
            #region 异常处理
            catch (Exception ex)
            {
                GetExceptionMsg(ex, "QxQ");
                NotifyIcon notifyIcon1 = new NotifyIcon();
                notifyIcon1.ShowBalloonTip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", System.Windows.Forms.ToolTipIcon.Error);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: NitroP/OSUplayer
        static void Main()
        {
            Application.SetCompatibleTextRenderingDefault(false);
            //设置应用程序处理异常方式:ThreadException处理
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += Application_ThreadException;
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            try
            {
                bool ret;
                _mutex = new Mutex(true, Application.ProductName, out ret);
                if (!ret)
                {
                    MessageBox.Show("The Program is already running!", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.ExitThread();
                    return;
                }
                Un4seen.Bass.BassNet.Registration(PrivateConfig.BassEmail, PrivateConfig.BassReg);
                ThemeResolutionService.LoadPackageResource("OSUplayer.Res.Light.tssp");
                ThemeResolutionService.ApplicationThemeName = "Light";
                LanguageManager.InitLanguage(System.Globalization.CultureInfo.CurrentCulture.Name);
                var mainwindow = new Main();
                mainwindow.Show();
                while (mainwindow.Created)
                {
                    Application.DoEvents();
                    Core.Render();
                    Thread.Sleep(5);
                }

                //   Application.Run(new Main());
            }
            #region 异常处理
            catch (Exception ex)
            {
                GetExceptionMsg(ex);
                NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", System.Windows.Forms.ToolTipIcon.Error);
            }
        }