public async Task <bool> StartService(IProgressObject progress = null) { var disposeProgress = progress == null; var result = false; try { progress = progress ?? this.GetProgressObject(String.Empty); // We need this one here in case the user stopped the service by other means if (InMaintenanceMode) { ServiceControlInstance.DisableMaintenanceMode(); } progress.Report(new ProgressDetails("Starting Service")); await Task.Run(() => result = ServiceControlInstance.TryStartService()); UpdateServiceProperties(); return(result); } finally { if (disposeProgress) { progress.Dispose(); } } }
public async Task <bool> StopService(IProgressObject progress = null) { var disposeProgress = progress == null; var result = false; try { progress = progress ?? this.GetProgressObject(String.Empty); progress.Report(new ProgressDetails("Stopping Service")); await Task.Run(() => { result = ServiceControlInstance.TryStopService(); if (InMaintenanceMode) { ServiceControlInstance.DisableMaintenanceMode(); } }); UpdateServiceProperties(); return(result); } finally { if (disposeProgress) { progress.Dispose(); } } }
public async Task <bool> StartServiceInMaintenanceMode(IProgressObject progress) { var disposeProgress = progress == null; var result = false; try { progress = progress ?? this.GetProgressObject(); progress.Report(new ProgressDetails("Starting Service")); await Task.Run(() => { ServiceControlInstance.EnableMaintenanceMode(); result = ServiceControlInstance.TryStartService(); }); return(result); } finally { if (disposeProgress) { progress.Dispose(); } } }