From 92777ba181437c111959565a2460e1fbe711be93 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 18 Nov 2019 17:15:40 +0900 Subject: [PATCH] Make sure SSH does not throw in separate thread --- .../Extensions/SSHClientExtensions.cs | 32 +++++++++++-------- Build/Version.csproj | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/BTCPayServer/Extensions/SSHClientExtensions.cs b/BTCPayServer/Extensions/SSHClientExtensions.cs index a8409523a..b47fa0e87 100644 --- a/BTCPayServer/Extensions/SSHClientExtensions.cs +++ b/BTCPayServer/Extensions/SSHClientExtensions.cs @@ -71,22 +71,26 @@ namespace BTCPayServer var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); new Thread(() => { - sshCommand.BeginExecute(ar => + try { - try + sshCommand.BeginExecute(ar => { - sshCommand.EndExecute(ar); - tcs.TrySetResult(CreateSSHCommandResult(sshCommand)); - } - catch (Exception ex) - { - tcs.TrySetException(ex); - } - finally - { - sshCommand.Dispose(); - } - }); + try + { + sshCommand.EndExecute(ar); + tcs.TrySetResult(CreateSSHCommandResult(sshCommand)); + } + catch (Exception ex) + { + tcs.TrySetException(ex); + } + finally + { + sshCommand.Dispose(); + } + }); + } + catch(Exception ex) { tcs.TrySetException(ex); } }) { IsBackground = true }.Start(); return tcs.Task; diff --git a/Build/Version.csproj b/Build/Version.csproj index 68648589a..f87c3f95e 100644 --- a/Build/Version.csproj +++ b/Build/Version.csproj @@ -1,5 +1,5 @@ - 1.0.3.139 + 1.0.3.141