-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
29 lines (26 loc) · 931 Bytes
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace MinecraftServerDownloader
{
public partial class App : System.Windows.Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// 订阅 DispatcherUnhandledException 事件
Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
}
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
// 处理异常
Exception exception = e.Exception;
// 进行异常处理逻辑,如记录异常信息、显示错误消息等
// 标记为已处理,以防止应用程序崩溃
e.Handled = true;
}
}
}