protected async void ExitedTryRestart(object sender, ProcessExitedArgs args) { // _stopped indicates if the process has been manually stopped; in which case, it should not be restarted. if (_stopped) { return; } Trace.TraceInformation("Host process exited, will attempt a restart."); await _process.ReleaseResources(); if (_restartCount >= _maximumRestartAttempts) { OnFailed("Process {0} has exited {1} times and won't be restarted; failure message {2}", _process.ExePath, _restartCount, args.Message); } else { try { await _process.Start(ExeArgs); ++_restartCount; } catch (Exception) { OnFailed("Process {0} has exited and could not be restarted; failure message {1}", _process.ExePath, args.Message); } } }
protected void OnProcessExited(object sender, ProcessExitedArgs e) { var handler = Exited; if (handler != null) { Trace.TraceInformation("The process for application {0} has exited unexpectedly", Identity); handler(this, new ApplicationExitedArgs { Message = e.Message, AppIdentity = Identity}); } }
protected async void ExitedTryRestart(object sender, ProcessExitedArgs args) { // _stopped indicates if the process has been manually stopped; in which case, it should not be restarted. if (_stopped) return; Trace.TraceInformation("Host process exited, will attempt a restart."); await _process.ReleaseResources(); if (_restartCount >= _maximumRestartAttempts) { OnFailed("Process {0} has exited {1} times and won't be restarted; failure message {2}", _process.ExePath, _restartCount, args.Message); } else { try { await _process.Start(); ++_restartCount; } catch (Exception) { OnFailed("Process {0} has exited and could not be restarted; failure message {1}", _process.ExePath, args.Message); } } }
protected void InvokeExited(object sender, ProcessExitedArgs args) { Exited?.Invoke(sender, args); }