2025-03-28 09:49:56 +08:00

74 lines
2.6 KiB
C#

using MyComputerFINA;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
namespace ConnectPoint
{
static class Program
{
private static System.Threading.Mutex mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
try
{
//处理未捕获的异常
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//处理UI线程异常
Application.ThreadException += Application_ThreadException;
//处理非UI线程异常
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new MainForm());
mutex = new System.Threading.Mutex(true, "ConnectPoint");
if (mutex.WaitOne(0, false))
{
Application.Run(new MyComputer());
}
else
{
Application.Exit();
}
}
catch (Exception ex)
{
ESSupport.Lib.LogHelper.WriteServiceLog(ex.ToString());
}
}
///<summary>
/// 这就是我们要在发生未处理异常时处理的方法,我这是写出错详细信息到文本,如出错后弹出一个漂亮的出错提示窗体,给大家做个参考
/// 做法很多,可以是把出错详细信息记录到文本、数据库,发送出错邮件到作者信箱或出错后重新初始化等等
/// 这就是仁者见仁智者见智,大家自己做了。
///</summary>
///<param name="sender"> </param>
///<param name="e"> </param>
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
var ex = e.Exception;
if (ex != null)
{
ESSupport.Lib.LogHelper.WriteServiceLog(ex.ToString());
}
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = e.ExceptionObject as Exception;
if (ex != null)
{
ESSupport.Lib.LogHelper.WriteServiceLog(ex.ToString());
}
}
}
}