File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
src/System.CommandLine/Invocation Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,20 @@ void Cancel(int forcedTerminationExitCode)
8080 {
8181 // request cancellation
8282 _handlerCancellationTokenSource . Cancel ( ) ;
83-
84- // wait for the configured interval
85- if ( ! _startedHandler . Wait ( _processTerminationTimeout ) )
83+
84+ try
85+ {
86+ // wait for the configured interval
87+ if ( ! _startedHandler . Wait ( _processTerminationTimeout ) )
88+ {
89+ // if the handler does not finish within configured time,
90+ // use the completion source to signal forced completion (preserving native exit code)
91+ ProcessTerminationCompletionSource . SetResult ( forcedTerminationExitCode ) ;
92+ }
93+ }
94+ catch ( AggregateException )
8695 {
87- // if the handler does not finish within configured time,
88- // use the completion source to signal forced completion (preserving native exit code)
89- ProcessTerminationCompletionSource . SetResult ( forcedTerminationExitCode ) ;
96+ // The task was cancelled or an exception was thrown during the task execution.
9097 }
9198 }
9299}
You can’t perform that action at this time.
0 commit comments