public async Task <int> TryExecute(string[] arguments) { _WindowsServiceController.Stop(); _Logger.LogInformation("Waiting for service to stop"); while (_WindowsServiceController.IsRunning() && !_ApplicationLifetimeManager.GracefulTerminationCancellationToken.IsCancellationRequested) { await Task.Delay(5000, _ApplicationLifetimeManager.GracefulTerminationCancellationToken).NotNull(); if (_ApplicationLifetimeManager.GracefulTerminationCancellationToken.IsCancellationRequested) { break; } _WindowsServiceController.QueryStatus(); } _Logger.LogInformation("Service successfully stopped"); return(0); }
public Task <int> TryExecute(string[] arguments) { _WindowsServiceController.QueryStatus(); return(Task.FromResult(0)); }