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> 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> 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();
                }
            }
        }
        async Task <bool> InstallInstance(ServiceControlNewInstance instanceData, IProgressObject progress)
        {
            var reportCard = await Task.Run(() => serviceControlInstaller.Add(instanceData, progress, PromptToProceed));

            if (reportCard.HasErrors || reportCard.HasWarnings)
            {
                windowManager.ShowActionReport(reportCard, "ISSUES ADDING INSTANCE", "Could not add new instance because of the following errors:", "There were some warnings while adding the instance:");
                return(true);
            }

            if (reportCard.CancelRequested)
            {
                return(true);
            }

            return(false);
        }