-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.xaml.cs
74 lines (70 loc) · 2.28 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using SodaCL.Core.Java;
using SodaCL.Launcher;
using SodaCL.Toolkits;
using System;
using System.Threading.Tasks;
using System.Windows;
using static SodaCL.Toolkits.Logger;
namespace SodaCL
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
StartExceptionCatcher();
foreach (var t in e.Args)
{
if (t == "--Langs")
{
//留个接口先
MessageBox.Show("您正处于翻译人员模式");
//bool isTranslator = true;
}
}
LauncherInit.Setup();
LauncherInit.DeleteTempFolder();
Task.Run(() => { JavaFindingAndSelecting.AutoJavaFinding(); });
//LauncherInit.InitMiSansFonts();
LogStart();
#if RELEASE
AppCenterManager.StartAppCenter();
var splashScreen = new SplashScreen("/Resources/Images/Dev.ico");
splashScreen.Show(true, true);
#endif
base.OnStartup(e);
Log(false, ModuleList.Main, LogInfo.Info, "显示启动画面");
Languages.MultiLanguages();
Log(false, ModuleList.Main, LogInfo.Info, "加载语言文件");
}
private void StartExceptionCatcher()
{
//Task线程内未捕获异常处理事件
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
var ex = e.Exception;
Log(true, ModuleList.Unknown, LogInfo.Unhandled,
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_Start") +
$"{ex.Message}\r\n{ex.StackTrace}" +
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_End"), ex);
};
//UI线程未捕获异常处理事件(UI主线程)
DispatcherUnhandledException += (sender, e) =>
{
var ex = e.Exception;
Log(true, ModuleList.Unknown, LogInfo.Unhandled,
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_Start") +
$"{ex.Message}\r\n{ex.StackTrace}" +
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_End"), ex); ;
};
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
var ex = e.ExceptionObject as Exception;
Log(true, ModuleList.Unknown, LogInfo.Unhandled,
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_Start") +
$"{ex.Message}\r\n{ex.StackTrace}" +
GetResources.GetText("ExceptionCatcher_Dialog_CatchedMessage_End"), ex);
};
}
}
}