Skip to content

Commit

Permalink
(GH-1224) longer timeouts - this time with feeling
Browse files Browse the repository at this point in the history
When the wait time is 0, do not set a timeout on the execute
task.Wait.
  • Loading branch information
ferventcoder committed Mar 31, 2017
1 parent f6d6ad4 commit 4634c43
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/chocolatey/infrastructure/commands/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ public T command<T>(Func<T> function, T timeoutDefaultValue)
cancelToken.Token.ThrowIfCancellationRequested();
var task = Task<T>.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();
Expand Down

0 comments on commit 4634c43

Please sign in to comment.