1 Star 0 Fork 8

zilin_zhang/fnsync

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
WindowUnhandledException.xaml.cs 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
holmium 提交于 2020-12-27 10:45 . Improves Performances
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace FnSync
{
/// <summary>
/// Interaction logic for WindowUnhandledException.xaml
/// </summary>
public partial class WindowUnhandledException : Window
{
public static void ShowException(Exception e)
{
Environment.SetEnvironmentVariable("LAST_ERROR_STRING", BuildString(e));
Environment.SetEnvironmentVariable("LAST_ERROR_PID", Process.GetCurrentProcess().Id.ToString());
Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, "-LE");
}
public WindowUnhandledException(Exception e) : this(BuildString(e))
{
}
public WindowUnhandledException(string e)
{
InitializeComponent();
Message.Text = e;
}
private static String BuildString(Exception e)
{
StringBuilder sb = new StringBuilder();
while (e != null)
{
if (sb.Length > 0)
{
sb.Append("\n\nCaused By:\n");
}
sb.Append(e.Message).Append('\n')
.Append(e.StackTrace);
e = e.InnerException;
}
sb.Append('\n');
return sb.ToString();
}
private void QuitThis_Click(object sender, RoutedEventArgs e)
{
Process.Start("taskkill", "/F /PID " + Environment.GetEnvironmentVariable("LAST_ERROR_PID"));
Close();
}
private void IgnoreThis_Click(object sender, RoutedEventArgs e)
{
Close();
}
protected override void OnClosing(CancelEventArgs e)
{
App.ExitApp();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/zilin__zhang/fnsync.git
git@gitee.com:zilin__zhang/fnsync.git
zilin__zhang
fnsync
fnsync
master

搜索帮助