From 9ce06dd26895256b04eb0845b74898d0b0c8c3ba Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 10 Jul 2023 09:33:35 -0400 Subject: [PATCH] Do not create processStartTcs unnecessarily --- src/Tgstation.Server.Host/System/ProcessExecutor.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index 1e5ea2e45a..874fd461c9 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -109,14 +109,14 @@ namespace Tgstation.Server.Host.System handle.StartInfo.UseShellExecute = !noShellExecute; - var processStartTcs = new TaskCompletionSource(); - Task readTask = null; CancellationTokenSource disposeCts = null; try { + TaskCompletionSource processStartTcs = null; if (readStandardHandles) { + processStartTcs = new TaskCompletionSource(); handle.StartInfo.RedirectStandardOutput = true; handle.StartInfo.RedirectStandardError = true; @@ -128,11 +128,11 @@ namespace Tgstation.Server.Host.System { handle.Start(); - processStartTcs.SetResult(); + processStartTcs?.SetResult(); } catch (Exception ex) { - processStartTcs.SetException(ex); + processStartTcs?.SetException(ex); throw; }