Fixed an issue where reconnecting doesn't await the handle in the second attempt.

This commit is contained in:
Burak Kaan Köse
2024-08-13 16:12:34 +02:00
parent 5912adff93
commit 8fe48ca438

View File

@@ -109,12 +109,12 @@ namespace Wino.Core.UWP.Services
{
try
{
ConnectingHandle ??= new TaskCompletionSource<bool>();
var connectionCancellationToken = new CancellationTokenSource(TimeSpan.FromMilliseconds(ServerConnectionTimeoutMs));
ConnectingHandle = new TaskCompletionSource<bool>();
Status = WinoServerConnectionStatus.Connecting;
var connectionCancellationToken = new CancellationTokenSource(TimeSpan.FromMilliseconds(ServerConnectionTimeoutMs));
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
// Connection establishment handler is in App.xaml.cs OnBackgroundActivated.
@@ -125,6 +125,14 @@ namespace Wino.Core.UWP.Services
Log.Information("Server connection established successfully.");
}
catch (OperationCanceledException canceledException)
{
Log.Error(canceledException, $"Server process did not start in {ServerConnectionTimeoutMs} ms. Operation is canceled.");
ConnectingHandle?.TrySetException(canceledException);
return false;
}
catch (Exception ex)
{
Log.Error(ex, "Failed to connect to the server.");