mirror of
https://github.com/LukeFZ/Il2CppInspectorRedux.git
synced 2026-03-22 00:18:18 +05:00
try and fix some of the ui deadlocking issues
This commit is contained in:
@@ -19,7 +19,7 @@ builder.Services.Configure<JsonHubProtocolOptions>(options =>
|
|||||||
builder.Services.AddFrontendCore();
|
builder.Services.AddFrontendCore();
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
|
|
||||||
var app = builder.Build();
|
await using var app = builder.Build();
|
||||||
|
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ builder.Services.AddFrontendCore();
|
|||||||
builder.Services.AddSingleton<UiProcessService>();
|
builder.Services.AddSingleton<UiProcessService>();
|
||||||
builder.Services.AddHostedService(p => p.GetRequiredService<UiProcessService>());
|
builder.Services.AddHostedService(p => p.GetRequiredService<UiProcessService>());
|
||||||
|
|
||||||
var app = builder.Build();
|
await using var app = builder.Build();
|
||||||
|
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.GUI;
|
||||||
|
|
||||||
@@ -9,11 +10,13 @@ public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundSer
|
|||||||
|
|
||||||
private Process? _uiProcess;
|
private Process? _uiProcess;
|
||||||
private string? _uiExectuablePath;
|
private string? _uiExectuablePath;
|
||||||
|
private readonly TaskCompletionSource _uiProcessCreatedTask = new();
|
||||||
|
|
||||||
public void LaunchUiProcess(int port)
|
public void LaunchUiProcess(int port)
|
||||||
{
|
{
|
||||||
_uiExectuablePath ??= ExtractUiExecutable();
|
_uiExectuablePath ??= ExtractUiExecutable();
|
||||||
_uiProcess = Process.Start(new ProcessStartInfo(_uiExectuablePath, [port.ToString()]));
|
_uiProcess = Process.Start(new ProcessStartInfo(_uiExectuablePath, [port.ToString()]));
|
||||||
|
_uiProcessCreatedTask.SetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ExtractUiExecutable()
|
private static string ExtractUiExecutable()
|
||||||
@@ -40,11 +43,17 @@ public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundSer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(_uiProcess))]
|
||||||
|
private async Task WaitForUiLaunchAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _uiProcessCreatedTask.Task.WaitAsync(cancellationToken);
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
Debug.Assert(_uiProcess != null);
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
while (_uiProcess == null)
|
await WaitForUiLaunchAsync(stoppingToken);
|
||||||
await Task.Delay(TimeSpan.FromMilliseconds(10), stoppingToken);
|
|
||||||
|
|
||||||
await _uiProcess.WaitForExitAsync(stoppingToken);
|
await _uiProcess.WaitForExitAsync(stoppingToken);
|
||||||
lifetime.StopApplication();
|
lifetime.StopApplication();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user