From 4634c4329e99abc4cf0ba93a925472508d76b904 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 30 Mar 2017 22:03:06 -0500 Subject: [PATCH] (GH-1224) longer timeouts - this time with feeling When the wait time is 0, do not set a timeout on the execute task.Wait. --- src/chocolatey/infrastructure/commands/Execute.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure/commands/Execute.cs b/src/chocolatey/infrastructure/commands/Execute.cs index 58777b163d..f19879017f 100644 --- a/src/chocolatey/infrastructure/commands/Execute.cs +++ b/src/chocolatey/infrastructure/commands/Execute.cs @@ -68,7 +68,16 @@ public T command(Func function, T timeoutDefaultValue) cancelToken.Token.ThrowIfCancellationRequested(); var task = Task.Factory.StartNew(function, cancelToken.Token); //,TaskCreationOptions.LongRunning| TaskCreationOptions.AttachedToParent); - task.Wait(_timespan); + if (_timespan.TotalSeconds < 1d) + { + // 0 means infinite + task.Wait(); + } + else + { + task.Wait(_timespan); + } + if (task.IsCompleted) return task.Result; cancelToken.Cancel();