コード例 #1
0
        private async Task <bool> StartServiceAsync()
        {
            // Check is service installed (applicable for Windows implementation)
            if (Platform.IsWindows && !__AppServices.IsServiceExists)
            {
                ProgressMessage = "";
                IsInProgress    = false;

                SetError(__AppServices.LocalizedString("ErrorCaption_IVPNServiceCouldNotStart"),
                         "IVPN Windows service was not found on computer. Please, reinstall the application.",
                         isHideStandardErrorDescription: true);

                return(false);
            }

            // Check is service started
            if (!__AppServices.IsServiceStarted)
            {
                ProgressMessage = __AppServices.LocalizedString("Starting_Service_Progress");
                IsInProgress    = true;

                ServiceStartResult result = await __AppServices.StartService();

                ProgressMessage = "";
                IsInProgress    = false;

                if (result.IsError)
                {
                    SetError(__AppServices.LocalizedString("ErrorCaption_IVPNServiceCouldNotStart"), result.ErrorMessage);

                    return(false);
                }
            }

            return(true);
        }