-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
42 lines (38 loc) · 1.15 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
using System;
using System.CodeDom;
using System.Windows;
using System.Runtime.ExceptionServices;
using FocusTreeManager.Helper;
namespace FocusTreeManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
//Log only if not in debug
#if DEBUG
public bool toLog = false;
#else
public bool toLog = true;
#endif
public App()
{
AsyncImageLoader.AsyncImageLoader.Worker.StartTheJob();
//Logging
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.FirstChanceException += HandleFirstChance;
currentDomain.UnhandledException += HandleCrashes;
}
private void HandleFirstChance(object source, FirstChanceExceptionEventArgs e)
{
if (!toLog) return;
LoggingHelper.LogException(e.Exception);
}
private void HandleCrashes(object sender, UnhandledExceptionEventArgs e)
{
if (!toLog) return;
LoggingHelper.LogCrash((Exception)e.ExceptionObject);
}
}
}