Cut over the window to Explorer.Host.exe so only the host writes the index.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Explorer.Hosting;
|
||||
using Explorer.Hosting.Ipc;
|
||||
using Explorer.Presentation.ViewModels;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -10,6 +12,7 @@ namespace Explorer.App;
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
private IHost? _host;
|
||||
private WorkbenchPipeClient? _workbenchClient;
|
||||
|
||||
protected override async void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
@@ -29,9 +32,35 @@ public partial class App : System.Windows.Application
|
||||
retainedFileCountLimit: 14)
|
||||
.CreateLogger();
|
||||
|
||||
_workbenchClient = await WorkbenchHostConnector.ConnectOrStartAsync(
|
||||
TimeSpan.FromSeconds(12),
|
||||
logger: null).ConfigureAwait(true);
|
||||
var hostExe = HostLogonAutostart.FindHostExecutable();
|
||||
if (_workbenchClient is null && hostExe is not null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Explorer.Host.exe is present but the window could not connect to it. See logs.",
|
||||
"Explorer Workbench",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
Shutdown(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
_host = Host.CreateDefaultBuilder()
|
||||
.UseSerilog()
|
||||
.ConfigureServices((_, services) => services.AddExplorer())
|
||||
.ConfigureServices((_, services) =>
|
||||
{
|
||||
if (_workbenchClient is not null)
|
||||
{
|
||||
services.AddExplorerClient(_workbenchClient);
|
||||
services.AddExplorerUi();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddExplorer();
|
||||
}
|
||||
})
|
||||
.Build();
|
||||
|
||||
var vm = _host.Services.GetRequiredService<MainViewModel>();
|
||||
@@ -60,6 +89,11 @@ public partial class App : System.Windows.Application
|
||||
_host.Dispose();
|
||||
}
|
||||
|
||||
if (_workbenchClient is not null)
|
||||
{
|
||||
await _workbenchClient.DisposeAsync().ConfigureAwait(true);
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
base.OnExit(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user