Esempio n. 1
0
        public IXApplication StartApplication(AppVersionInfo vers, StartupOptions_e opts, CancellationToken cancellationToken)
        {
            var args = new List <string>();

            if (opts.HasFlag(StartupOptions_e.Safe))
            {
                args.Add(SwApplication.CommandLineArguments.SafeMode);
            }

            if (opts.HasFlag(StartupOptions_e.Background))
            {
                args.Add(SwApplication.CommandLineArguments.BackgroundMode);
            }

            if (opts.HasFlag(StartupOptions_e.Silent))
            {
                args.Add(SwApplication.CommandLineArguments.SilentMode);
            }

            var app = SwApplication.Start(((SwAppVersionInfo)vers).Version,
                                          string.Join(" ", args),
                                          cancellationToken);

            app.Sw.CommandInProgress = true;

            return(app);
        }
Esempio n. 2
0
        public IXApplication StartApplication(IXVersion vers, StartupOptions_e opts,
                                              CancellationToken cancellationToken)
        {
            var app = SwApplicationFactory.PreCreate();

            app.State   = ApplicationState_e.Default;
            app.Version = (ISwVersion)vers;

            app.CustomServices = m_CustomServices;

            List <string> forceDisabledAddIns = null;

            if (opts.HasFlag(StartupOptions_e.Safe))
            {
                app.State |= ApplicationState_e.Safe;
                TryDisableAddIns(out forceDisabledAddIns);
            }

            if (opts.HasFlag(StartupOptions_e.Background))
            {
                app.State |= ApplicationState_e.Background;
            }

            if (opts.HasFlag(StartupOptions_e.Silent))
            {
                app.State |= ApplicationState_e.Silent;
            }

            if (opts.HasFlag(StartupOptions_e.Hidden))
            {
                app.State |= ApplicationState_e.Hidden;
            }

            try
            {
                app.Commit(cancellationToken);
            }
            finally
            {
                if (forceDisabledAddIns != null)
                {
                    TryEnableAddIns(forceDisabledAddIns);
                }
            }

            app.Sw.UserControlBackground = true;
            app.Sw.CommandInProgress     = true;

            //Note. By some reasons the process from IXApplication::Process does not fire exited event
            var prc = Process.GetProcessById(app.Process.Id);

            prc.EnableRaisingEvents = true;
            prc.Exited += OnProcessExited;
            m_ForceDisabledAddIns.Add(prc, forceDisabledAddIns);

            return(app);
        }
Esempio n. 3
0
        private IXApplication StartApplication(IXVersion versionInfo,
                                               StartupOptions_e opts, CancellationToken cancellationToken)
        {
            m_JournalWriter.WriteLine($"Starting host application: {versionInfo.DisplayName}");

            IXApplication app;

            try
            {
                app = m_AppProvider.StartApplication(versionInfo,
                                                     opts, p => TryAddProcessToJob(p), cancellationToken);

                if (opts.HasFlag(StartupOptions_e.Silent))
                {
                    m_PopupKiller.Start(app.Process, TimeSpan.FromSeconds(POPUP_KILLER_PING_SECS));
                }
            }
            catch (Exception ex)
            {
                throw new UserException("Failed to start host application", ex);
            }

            return(app);
        }