コード例 #1
0
        public override void InternalExecute(int maxThreads)
        {
            try
            {
                Logger.WriteToLog("Processing genome '{0}' with {1} threads", Genome.Directory, maxThreads);

                var jobs = new List <IJob>();

                foreach (var chrName in Genome.ChromosomesToProcess)
                {
                    foreach (var inputFile in _inputFiles)
                    {
                        var job = new ExternalProcessJob(chrName)
                        {
                            ExecutablePath       = _exePath,
                            CommandLineArguments = GetCommandLineArgs(chrName, inputFile)
                        };

                        if (Utilities.IsThisMono())
                        {
                            string discoveredMono = Utilities.GetMonoPath();
                            job.CommandLineArguments = job.ExecutablePath + " " + job.CommandLineArguments;
                            job.ExecutablePath       = _monoPath ?? discoveredMono;

                            Logger.WriteToLog(string.Format("Mono path from command line is {0}", _monoPath ?? "empty"));
                            Logger.WriteToLog(string.Format("Mono path discovered is {0}", discoveredMono ?? "empty"));


                            if ((string.IsNullOrEmpty(_monoPath)) && (string.IsNullOrEmpty(discoveredMono)))
                            {
                                Logger.WriteToLog(string.Format("Warning: Unable to determine mono path."));
                            }

                            if (!(string.IsNullOrEmpty(_monoPath)) && !(string.IsNullOrEmpty(discoveredMono)))
                            {
                                if (_monoPath != discoveredMono)
                                {
                                    Logger.WriteToLog(
                                        string.Format(
                                            "Warning: Mono path from command line does not match mono version discovered"));
                                }
                            }

                            Logger.WriteToLog(string.Format("Mono path {0} will be used.", job.ExecutablePath));
                        }

                        Logger.WriteToLog(string.Format("Launching process: {0} {1}", job.ExecutablePath,
                                                        job.CommandLineArguments));

                        jobs.Add(job);
                    }
                }

                JobManager.Process(jobs); // process all jobs
            }
            finally
            {
                Finish();
            }
        }
コード例 #2
0
        public void CancellingKillsTheProcess()
        {
            var jobManager  = new JobManager(3, JobErrorHandlingMode.Terminate);
            var externalJob = new ExternalProcessJob("foo")
            {
                ExecutablePath = "notepad.exe"
            };
            var jobs = new List <IJob>
            {
                externalJob,
                new GenericJob(() =>
                {
                    while (!externalJob.Started)
                    {
                        Thread.Sleep(100);
                    }
                    // the program should have started by now - trigger the error
                    throw new ApplicationException("Bad monkey");
                })
            };

            Assert.Throws <ApplicationException>(() => jobManager.Process(jobs));
            Assert.True(externalJob.Terminated);
        }