Ejemplo n.º 1
0
        private static ExitKind RunSingleInstance(IReadOnlyCollection <string> rawArgs, ServerModeStatusAndPerf?serverModeStatusAndPerf = null)
        {
            using (var args = new Args())
            {
                var pathTable = new PathTable();

                ICommandLineConfiguration configuration;
                ContentHashingUtilities.SetContentHasherIdlePoolSize(10);
                if (!args.TryParse(rawArgs.ToArray(), pathTable, out configuration))
                {
                    return(ExitKind.InvalidCommandLine);
                }

                string clientPath     = AssemblyHelper.GetThisProgramExeLocation();
                var    rawArgsWithExe = new List <string>(rawArgs.Count + 1)
                {
                    clientPath
                };
                rawArgsWithExe.AddRange(rawArgs);

                using (var app = new BuildXLApp(
                           new SingleInstanceHost(),
                           null,

                           // BuildXLApp will create a standard console.
                           configuration,
                           pathTable,
                           rawArgsWithExe,
                           null,
                           serverModeStatusAndPerf))
                {
                    Console.CancelKeyPress +=
                        (sender, eventArgs) =>
                    {
                        eventArgs.Cancel = !app.OnConsoleCancelEvent(isTermination: eventArgs.SpecialKey == ConsoleSpecialKey.ControlBreak);
                    };

                    return(app.Run().ExitKind);
                }
            }
        }