forked from visualHFT/VisualHFT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
72 lines (63 loc) · 2.02 KB
/
App.xaml.cs
File metadata and controls
72 lines (63 loc) · 2.02 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using VisualHFT.PluginManager;
namespace VisualHFT
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//Initialize logging
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
//Launch the GC cleanup thread
Task.Run(async () => { await GCCleanupAsync(); });
//Load Plugins
Task.Run(async () =>
{
try
{
await LoadPlugins();
}
catch (Exception ex)
{
// Handle the exception
Application.Current.Dispatcher.Invoke(() =>
{
MessageBox.Show("ERROR LOADING Plugins: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
});
}
});
}
protected override void OnExit(ExitEventArgs e)
{
PluginManager.PluginManager.UnloadPlugins();
base.OnExit(e);
}
private async Task LoadPlugins()
{
PluginManager.PluginManager.AllPluginsReloaded = false;
PluginManager.PluginManager.LoadPlugins();
PluginManager.PluginManager.StartPlugins();
PluginManager.PluginManager.AllPluginsReloaded = true;
}
private async Task GCCleanupAsync()
{
//due to the high volume of data do this periodically.(this will get fired every 5 secs)
while (true)
{
await Task.Delay(5000);
GC.Collect(); //force garbage collection
};
}
}
}