Repository navigation
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
54 lines (46 loc) · 2.01 KB
/
Copy pathApp.xaml.cs
File metadata and controls
54 lines (46 loc) · 2.01 KB
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
using System;
using System.Configuration;
using System.Data;
using System.Threading.Tasks;
using System.Windows;
namespace HttpTraceAnalyser
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Globally disable link detection in all AvalonEdit controls to prevent
// regex catastrophic backtracking that causes UI hangs on large files
AvalonEditHelper.DisableLinkDetectionGlobally();
// Discover and load additional trace parser plugins (see Model/Extensibility)
// before any trace file is opened, so their loaders/extended fields are registered.
Model.Extensibility.PluginManager.LoadPlugins();
ThemeManager.Apply(AppSettings.EffectiveTheme);
McpHostManager.PipeNameSuffix = AppSettings.McpPipeNameSuffix;
}
protected override void OnExit(ExitEventArgs e)
{
// Run the shutdown off the UI thread and with ConfigureAwait(false): StopAsync's
// internal continuations must not need to resume on the WPF dispatcher, which is
// already tearing down at this point and would otherwise deadlock the call below.
try
{
Task.Run(() => McpHostManager.StopAsync()).Wait(TimeSpan.FromSeconds(5));
}
catch
{
// Server may not have been running, or already been torn down/timed out;
// fall through and force-exit the process regardless.
}
base.OnExit(e);
// Kestrel can leave background threads (e.g. from the HTTP listener) alive even
// after the host reports stopped, which would otherwise keep the process running
// after the last window closes. Force the process to end now that cleanup is done.
Environment.Exit(0);
}
}
}