namespace TagTools
{
/*
* Check by lance at 2019/3/13
*
*/
using System;
using System.Threading;
using System.Windows.Forms;
internal static class Program
{
public static EventWaitHandle ProgramStarted;
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception exceptionObject = (Exception) e.ExceptionObject;
//
LogHelper.WriteLog(typeof(Program), exceptionObject);
}
// 应用程序的主入口点。
[STAThread]
private static void Main()
{
// 尝试创建一个命名事件
bool flag;
//AppDomain(应用程序域)
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "3GTagToolStartEvent", out flag);
// 如果该命名事件已经存在(存在有前一个运行实例),则发事件通知并退出
if (!flag)
{
ProgramStarted.Set();
}
else
{
Application.SetCompatibleTextRenderingDefault(false);//见注释
Application.EnableVisualStyles();
//启动主要窗口
MainForm mainForm = new MainForm();
Application.Run(mainForm);
}
}
}
}
/*
注释:
1.作用:在应用程序范围内设置控件显示文本的默认方式(可以设为使用新的GDI+,还是旧的GDI),true使用GDI+方式显示文本, false使用GDI方式显示文本。
2.只能在单独运行窗体的程序中调用该方法;不能在插件式的程序中调用该方法。
3.只能在程序创建任何窗体前调用该方法,否则会引发InvalidOperationException异常。
*/
网友评论