Пример #1
0
        public static Aapt2Daemon GetInstance(IBuildEngine4 engine, string aapt2, int numberOfInstances, int initalNumberOfDaemons, bool registerInDomain = false)
        {
            var area   = registerInDomain ? RegisteredTaskObjectLifetime.AppDomain : RegisteredTaskObjectLifetime.Build;
            var daemon = engine.GetRegisteredTaskObjectAssemblyLocal <Aapt2Daemon> (RegisterTaskObjectKey, area);

            if (daemon == null)
            {
                daemon = new Aapt2Daemon(aapt2, numberOfInstances, initalNumberOfDaemons);
                engine.RegisterTaskObjectAssemblyLocal(RegisterTaskObjectKey, daemon, area, allowEarlyCollection: false);
            }
            return(daemon);
        }
Пример #2
0
        public static Aapt2Daemon GetInstance(IBuildEngine4 engine, string aapt2, int numberOfInstances, int initalNumberOfDaemons, bool registerInDomain = false)
        {
            var         area   = registerInDomain ? RegisteredTaskObjectLifetime.AppDomain : RegisteredTaskObjectLifetime.Build;
            Aapt2Daemon daemon = (Aapt2Daemon)engine.GetRegisteredTaskObject(typeof(Aapt2Daemon).FullName, area);

            if (daemon == null)
            {
                daemon = new Aapt2Daemon(aapt2, numberOfInstances, initalNumberOfDaemons);
                engine.RegisterTaskObject(typeof(Aapt2Daemon).FullName, daemon, area, allowEarlyCollection: false);
            }
            return(daemon);
        }
Пример #3
0
        public override bool Execute()
        {
            // Must register on the UI thread!
            // We don't want to use up ALL the available cores especially when
            // running in the IDE. So lets cap it at DefaultMaxAapt2Daemons (6).
            int maxInstances = Math.Min(Math.Max(1, ProcessorCount - 1), DefaultMaxAapt2Daemons);

            if (DaemonMaxInstanceCount == 0)
            {
                DaemonMaxInstanceCount = maxInstances;
            }
            else
            {
                DaemonMaxInstanceCount = Math.Min(DaemonMaxInstanceCount, maxInstances);
            }
            daemon = Aapt2Daemon.GetInstance(BuildEngine4, GenerateFullPathToTool(),
                                             DaemonMaxInstanceCount, GetRequiredDaemonInstances(), registerInDomain: DaemonKeepInDomain);
            return(base.Execute());
        }