Skip to content

Commit 487ae56

Browse files
committed
Test fix dependency injection installer issue 1
1 parent 0391e7e commit 487ae56

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.IO;
34
using System.Text;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -35,10 +36,36 @@ public partial class App : IDisposable, ISingleInstanceApp
3536
public App()
3637
{
3738
// Initialize settings
39+
WriteToLogFile(1);
3840
var storage = new FlowLauncherJsonStorage<Settings>();
39-
_settings = storage.Load();
40-
_settings.SetStorage(storage);
41-
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
41+
WriteToLogFile(2);
42+
try
43+
{
44+
_settings = storage.Load();
45+
}
46+
catch (Exception ex)
47+
{
48+
WriteToLogFile(ex.Message);
49+
}
50+
WriteToLogFile(3);
51+
try
52+
{
53+
_settings.SetStorage(storage);
54+
}
55+
catch (Exception ex)
56+
{
57+
WriteToLogFile(ex.Message);
58+
}
59+
WriteToLogFile(4);
60+
try
61+
{
62+
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
63+
}
64+
catch (Exception ex)
65+
{
66+
WriteToLogFile(ex.Message);
67+
}
68+
WriteToLogFile(5);
4269

4370
// Configure the dependency injection container
4471
var host = Host.CreateDefaultBuilder()
@@ -55,30 +82,55 @@ public App()
5582
.AddSingleton<MainViewModel>()
5683
.AddSingleton<Theme>()
5784
).Build();
85+
WriteToLogFile(6);
5886
Ioc.Default.ConfigureServices(host.Services);
87+
WriteToLogFile(7);
5988

6089
// Initialize the public API and Settings first
6190
API = Ioc.Default.GetRequiredService<IPublicAPI>();
91+
WriteToLogFile(8);
6292
_settings.Initialize();
93+
WriteToLogFile(9);
94+
}
95+
96+
private static void WriteToLogFile(string message)
97+
{
98+
// d:\LOG.TXT
99+
using var sw = new StreamWriter("d:\\LOG.TXT", true);
100+
sw.WriteLine($" {message} ");
101+
}
102+
103+
private static void WriteToLogFile(int message)
104+
{
105+
// d:\LOG.TXT
106+
using var sw = new StreamWriter("d:\\LOG.TXT", true);
107+
sw.WriteLine($" {message} ");
63108
}
64109

65110
[STAThread]
66111
public static void Main()
67112
{
113+
WriteToLogFile("A");
68114
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
69115
{
116+
WriteToLogFile("B");
70117
using (var application = new App())
71118
{
119+
WriteToLogFile("C");
72120
application.InitializeComponent();
121+
WriteToLogFile("D");
73122
application.Run();
123+
WriteToLogFile("E");
74124
}
75125
}
76126
}
77127

78128
private async void OnStartupAsync(object sender, StartupEventArgs e)
79129
{
130+
WriteToLogFile(10);
80131
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
81132
{
133+
WriteToLogFile(11);
82134
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
83135

84136
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");

0 commit comments

Comments
 (0)