123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using ComponentFactory.Krypton.Toolkit;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading;
- using System.Windows.Forms;
- namespace Falit.Run
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- public static ApplicationContext context;
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- //try
- //{
- Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
- //Application.ThreadException += Application_ThreadException;
- //AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- var processName = Process.GetCurrentProcess().ProcessName;
- if ((Process.GetProcessesByName(processName)).GetUpperBound(0) > 0)
- {
- KryptonMessageBox.Show(@"系统已经在运行中,如果要重新启动,请从进程中关闭...", @"系统警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- var upgrade = new FrmUpgrade();
- upgrade.Show();
- //context = new ApplicationContext();
- //context.Tag = upgrade;
- //Application.Idle += Application_Idle; //注册程序运行空闲去执行主程序窗体相应初始化代码
- Application.Run(upgrade);
- }
- //}
- //catch (Exception ex)
- //{
- // KryptonMessageBox.Show("系统出现未知异常,请重启系统:" + ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- //}
- }
- //private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- //{
- // var ex = e.Exception.InnerException;
- // if (ex != null)
- // {
- // KryptonMessageBox.Show("系统出现未知异常," + ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- // }
- //}
- //private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- //{
- // var ex = e.ExceptionObject as Exception;
- // if (ex != null)
- // {
- // KryptonMessageBox.Show("系统出现未知异常," + ex.InnerException.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- // }
- //}
- //private static void Application_Idle(object sender, EventArgs e)
- //{
- // Application.Idle -= Application_Idle;
- // if (context.MainForm == null)
- // {
- // var login = new FrmUpgrade();
- // context.MainForm = login;
- // var sp = (FrmUpgrade)context.Tag;
- // sp.Close();
- // login.Show();
- // }
- //}
- }
- }
|