コード例 #1
0
ファイル: Runner.cs プロジェクト: peter-devoil/ApsimX
        /// <summary>
        /// Run all simulations.
        /// </summary>
        /// <returns>A list of exception or null if no exceptions thrown.</returns>
        public List <Exception> Run()
        {
            startTime = DateTime.Now;

            if (jobs.Count > 0)
            {
                jobRunner = null;

                switch (runType)
                {
                case RunTypeEnum.SingleThreaded:
                    jobRunner = new JobRunner(numProcessors: 1);
                    break;

                case RunTypeEnum.MultiThreaded:
                    jobRunner = new JobRunner(numberOfProcessors);
                    break;
                }

                jobRunner.JobCompleted += OnJobCompleted;
                jobRunner.AllCompleted += OnAllCompleted;

                // Run all simulations.
                jobs.ForEach(j => jobRunner.Add(j));
                jobRunner.Run(wait);
            }
            else
            {
                OnAllCompleted(this, new AllCompleteArguments());
            }

            return(ExceptionsThrown);
        }
コード例 #2
0
 /// <summary>
 /// Use the given job runner to run jobs.
 /// </summary>
 /// <param name="runner">The job runner to be used.</param>
 public void Use(JobRunner runner)
 {
     jobRunner               = runner;
     useFixedRunner          = true;
     jobRunner.JobCompleted += OnJobCompleted;
     jobRunner.AllCompleted += OnAllCompleted;
     jobs.ForEach(j => jobRunner.Add(j));
 }
コード例 #3
0
        public void RunSimulations(string[] files)
        {
            // Clear the run queue, add the specified files, and then run them.
            Clear();

            try
            {
                bool JustDoIt = false;

                for (int i = 0; i != files.Length; i++)
                {
                    string FileName = files[i].Replace("\"", ""); // remove double quotes.
                    if (FileName == "/auto")
                    {
                        JustDoIt = true;
                    }
                    else if (FileName == "/autoclose")
                    {
                        AutoClose = true;
                    }
                    else if (Path.GetExtension(FileName).ToLower() == ".sim")
                    {
                        _JobRunner.Add(new RunSimFile(FileName, _JobRunner));
                    }
                    else
                    {
                        AddFile(FileName, JustDoIt);
                    }
                }

                Timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
 /// <summary>Create a command runner one hasn't already been created.</summary>
 private void Start()
 {
     if (commandRunner == null)
     {
         lock (lockObject)
         {
             if (commandRunner == null)
             {
                 stopping      = false;
                 commandRunner = new JobRunner(numProcessors: 1);
                 commandRunner.Add(this);
                 commandRunner.Run();
                 ReadExistingDatabase(Connection);
             }
         }
     }
 }