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)
80
80
{
81
81
// request cancellation
82
82
_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 )
86
95
{
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.
90
97
}
91
98
}
92
99
}
You can’t perform that action at this time.
0 commit comments