Commit 85133af5 authored by 段廷瑞's avatar 段廷瑞

1、增加未处理异常监控

parent 6fc6ee7b
......@@ -282,6 +282,17 @@ namespace Tools.MyUtils
var result = MessageBox.Show(msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return result == DialogResult.Yes;
}
/// <summary>
/// 异常提示
/// </summary>
/// <param name="e"></param>
public static void TipException(Exception e)
{
if (e != null)
{
Tip($"错误消息:{e.Message}\r\n调用堆栈:\r\n{e.StackTrace}", 600, 400);
}
}
/// <summary>
/// 显示帮助信息
......
......@@ -5,6 +5,8 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
//
using Tools.MyUtils;
namespace Tools
{
......@@ -16,10 +18,23 @@ namespace Tools
[STAThread]
static void Main()
{
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new wMain());
}
//UI未处理异常
private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Utils.TipException(e.Exception);
}
//非UI未处理异常
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Utils.TipException(e.ExceptionObject as Exception);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment