Example #1
0
        /// <summary>
        /// Updates the simulation
        /// </summary>
        /// <param name="step"></param>
        public void Update(TimeSpan step)
        {
            // If there is still an update in progress ignore the call
            if (this.threadsToCompleteCount != this.completedThreadsCount)
            {
                throw new Exception("Tried to call .Update() while another update is still running");
            }

            SimulationContext context = this.GetContext();

            threadsToCompleteCount = 0;
            completedThreadsCount  = 0;

            // Start threads
            foreach (var item in this.Threads)
            {
                threadsToCompleteCount++;
                item.ProcessEngines(context, step);
            }

            foreach (var item in this.Threads)
            {
                item.Thread.Join();
            }
        }
Example #2
0
 /// <summary>
 /// Executes the engines
 /// </summary>
 /// <param name="threadStartContext"></param>
 public void ProcessEngines(SimulationContext threadStartContext, TimeSpan step)
 {
     this.Thread = new Thread(new ParameterizedThreadStart(ThreadProcessEngines));
     this.Thread.Start(new SimulationEngineThreadStart()
     {
         Context = threadStartContext, Step = step
     });
 }
Example #3
0
 public abstract void UpdateWorld(SimulationContext context, TimeSpan step);