From 8fe48ca43887d8007e6a275c85c9f12ccf57335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Tue, 13 Aug 2024 16:12:34 +0200 Subject: [PATCH] Fixed an issue where reconnecting doesn't await the handle in the second attempt. --- .../Services/WinoServerConnectionManager.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs index bb5fd965..3243373e 100644 --- a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs +++ b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs @@ -109,12 +109,12 @@ namespace Wino.Core.UWP.Services { try { - ConnectingHandle ??= new TaskCompletionSource(); - - var connectionCancellationToken = new CancellationTokenSource(TimeSpan.FromMilliseconds(ServerConnectionTimeoutMs)); + ConnectingHandle = new TaskCompletionSource(); 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.");