(refactor): clean up child processes on cancel
This commit is contained in:
parent
c52e3db122
commit
635423b083
@ -51,10 +51,13 @@ namespace UScheduler.BackgroundServices {
|
||||
// When the stopping token is canceled, for example, a call made from services.msc,
|
||||
// we shouldn't exit with a non-zero exit code. In other words, this is expected...
|
||||
_logger.LogInformation("Stopping PSScriptBackgroundService due to cancellation request");
|
||||
_psScriptService.TerminateAllScripts();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
|
||||
_psScriptService.TerminateAllScripts();
|
||||
|
||||
// Terminates this process and returns an exit code to the operating system.
|
||||
// This is required to avoid the 'BackgroundServiceExceptionBehavior', which
|
||||
// performs one of two scenarios:
|
||||
|
||||
@ -55,10 +55,13 @@ public sealed class ProcessBackgroundService : BackgroundService {
|
||||
// When the stopping token is canceled, for example, a call made from services.msc,
|
||||
// we shouldn't exit with a non-zero exit code. In other words, this is expected...
|
||||
_logger.LogInformation("Stopping ProcessBackgroundService due to cancellation request");
|
||||
_processService.TerminateAllProcesses();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex, "{Message}", ex.Message);
|
||||
|
||||
_processService.TerminateAllProcesses();
|
||||
|
||||
// Terminates this process and returns an exit code to the operating system.
|
||||
// This is required to avoid the 'BackgroundServiceExceptionBehavior', which
|
||||
// performs one of two scenarios:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user