Skip to content
代码片段 群组 项目
未验证 提交 6940249d 编辑于 作者: Stephen Halter's avatar Stephen Halter 提交者: GitHub
浏览文件

Handle exception thrown by ProcessName during ProcessEx timeout (#23990)


* Handle exception thrown by ProcessName during ProcessEx timeout

* Update src/Shared/Process/ProcessEx.cs

Co-authored-by: default avatarBrennan <brecon@microsoft.com>

* PR feedback

Co-authored-by: default avatarBrennan <brecon@microsoft.com>
上级 5bc2c49e
No related branches found
No related tags found
无相关合并请求
...@@ -49,10 +49,15 @@ namespace Microsoft.AspNetCore.Internal ...@@ -49,10 +49,15 @@ namespace Microsoft.AspNetCore.Internal
_exited = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously); _exited = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
// We greedily create a timeout exception message even though a timeout is unlikely to happen for two reasons:
// 1. To make it less likely for Process getters to throw exceptions like "System.InvalidOperationException: Process has exited, ..."
// 2. To ensure if/when exceptions are thrown from Process getters, these exceptions can easily be observed.
var timeoutExMessage = $"Process proc {proc.ProcessName} {proc.StartInfo.Arguments} timed out after {DefaultProcessTimeout}.";
_processTimeoutCts = new CancellationTokenSource(timeout); _processTimeoutCts = new CancellationTokenSource(timeout);
_processTimeoutCts.Token.Register(() => _processTimeoutCts.Token.Register(() =>
{ {
_exited.TrySetException(new TimeoutException($"Process proc {proc.ProcessName} {proc.StartInfo.Arguments} timed out after {DefaultProcessTimeout}.")); _exited.TrySetException(new TimeoutException(timeoutExMessage));
}); });
} }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册