Exemplo n.º 1
0
        protected internal override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            if (SingleStartup)
            {
                if (StartupItem == null)
                {
                    monitor.ReportError(GettextCatalog.GetString("Startup item not set"), null);
                    return;
                }
                StartupItem.Execute(monitor, context, configuration);
            }
            else
            {
                List <IAsyncOperation> list = new List <IAsyncOperation> ();
                monitor.BeginTask("Executing projects", 1);

                SynchronizedProgressMonitor syncMonitor = new SynchronizedProgressMonitor(monitor);

                foreach (SolutionEntityItem it in MultiStartupItems)
                {
                    if (!it.CanExecute(context, configuration))
                    {
                        continue;
                    }
                    AggregatedProgressMonitor mon = new AggregatedProgressMonitor();
                    mon.AddSlaveMonitor(syncMonitor, MonitorAction.ReportError | MonitorAction.ReportWarning | MonitorAction.SlaveCancel);
                    list.Add(mon.AsyncOperation);
                    SolutionEntityItem cit = it;

                    Thread t = new Thread(delegate()
                    {
                        try
                        {
                            using (mon)
                            {
                                cit.Execute(mon, context, configuration);
                            }
                        }
                        catch (Exception ex)
                        {
                            LoggingService.LogError("Project execution failed", ex);
                        }
                    });
                    t.Name         = "Project execution";
                    t.IsBackground = true;
                    t.Start();
                }
                foreach (IAsyncOperation op in list)
                {
                    op.WaitForCompleted();
                }

                monitor.EndTask();
            }
        }