hisence-yolo-detection/HisenceYoloDetection/Program.cs
2024-05-31 10:14:57 +08:00

68 lines
2.3 KiB
C#

namespace HisenceYoloDetection
{
internal static class Program
{
static MainForm? mainFrm = null;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
mainFrm = new MainForm();
Application.Run(mainFrm);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
}catch (Exception ex)
{
}
}
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
string msg = e.Exception.Message;
using (StreamWriter sw = new StreamWriter("D://ThreadException.log", true))
{
sw.WriteLine("================================");
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
sw.WriteLine(msg);
sw.Flush();
}
if (mainFrm != null)
{
// mainFrm.DockFrm_OnLogMsgOutput(new LogMsg(DateTime.Now, EnumHelper.LogLevel.Exception, msg));
}
//MessageBox.Show(msg, "Ïß³ÌÒì³£±¨¾¯");
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
string msg = (e.ExceptionObject as Exception).Message;
using (StreamWriter sw = new StreamWriter("D://UnhandledException.log", true))
{
sw.WriteLine("================================");
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
sw.WriteLine(msg);
sw.Flush();
}
if (mainFrm != null)
{
//mainFrm.DockFrm_OnLogMsgOutput(new LogMsg(DateTime.Now, EnumHelper.LogLevel.Exception, msg));
//MessageBox.Show(msg, "δ´¦ÀíÒì³£");
}
}
}
}