Example #1
0
        private bool Install(InstallThreadParam param)
        {
            if (_context.IsValidContext() == true)
            {
                bool result    = false;
                bool debugMode = true;
                if (license)
                {
                    debugMode = false;
                }
                if (param.operation == XapInstallOperationType.Install)
                {
                    result = _context.Install(debugMode);
                }
                else if (param.operation == XapInstallOperationType.Update)
                {
                    result = _context.Update(debugMode);
                }
                else
                {
                    result = _context.Uninstall();
                }

                if (result && param.report)
                {
                    while (true)
                    {
                        ApplicationEvent evt = _context.WaitForEvent();
                        if (StateChanged != null)
                        {
                            XapInstallEventArgs e = new XapInstallEventArgs();
                            e.application = _context;
                            e.fileName    = param.fileName;
                            e.progress    = evt.progress;
                            e.state       = evt.state;
                            e.error       = evt.error;
                            Deployment.Current.Dispatcher.BeginInvoke(delegate() { StateChanged(this, e); });
                        }
                        if ((evt.state == InstallationState.AppInstallCompleted && param.operation == XapInstallOperationType.Install) ||
                            (evt.state == InstallationState.AppUpdateCompleted && param.operation == XapInstallOperationType.Update) ||
                            (evt.state == InstallationState.AppRemoveCompleted && param.operation == XapInstallOperationType.Uninstall))
                        {
                            break;
                        }
                    }
                }
                return(result);
            }
            return(false);
        }
        private bool Install(InstallThreadParam param)
        {
            if (_context.IsValidContext() == true)
            {
                bool result = false;
                bool debugMode = true;
                if (license)
                    debugMode = false;
                if (param.operation == XapInstallOperationType.Install)
                    result = _context.Install(debugMode);
                else if (param.operation == XapInstallOperationType.Update)
                    result = _context.Update(debugMode);
                else
                    result = _context.Uninstall();

                if (result && param.report)
                {
                    while (true)
                    {
                        ApplicationEvent evt = _context.WaitForEvent();
                        if (StateChanged != null)
                        {
                            XapInstallEventArgs e = new XapInstallEventArgs();
                            e.application = _context;
                            e.fileName = param.fileName;
                            e.progress = evt.progress;
                            e.state = evt.state;
                            e.error = evt.error;
                            Deployment.Current.Dispatcher.BeginInvoke(delegate() { StateChanged(this, e); });
                        }
                        if ((evt.state == InstallationState.AppInstallCompleted && param.operation == XapInstallOperationType.Install) ||
                            (evt.state == InstallationState.AppUpdateCompleted && param.operation == XapInstallOperationType.Update) ||
                            (evt.state == InstallationState.AppRemoveCompleted && param.operation == XapInstallOperationType.Uninstall))
                        {
                            break;
                        }
                    }
                }
                return result;
            }
            return false;
        }