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();