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(); } } }