/// <summary> /// Updates a 3D aggregate based on current contents of dla_3d batch_queue - processes this /// batch_queue and adds its contents to the simulation view. /// </summary> /// <param name="source"></param> /// <param name="e"></param> private void Aggregate3DUpdateOnTimedEvent(object source, ElapsedEventArgs e) { // lock around aggregate updating and batch queue processing to prevent // non-dereferencable std::deque iterator run-time errors lock (locker) { // get and process the batch_queue from the DLA handle BlockingCollection <Tuple <int, int, int> > blocking_queue = dla_3d.ProcessBatchQueue(); // loop over blocking_queue adding contents to interface and dequeueing on each iteration while (blocking_queue.Count != 0) { Tuple <int, int, int> agg_tuple = blocking_queue.Take(); Point3D pos = new Point3D(agg_tuple.Item1, agg_tuple.Item2, agg_tuple.Item3); aggregate_manager.AddParticle(pos, colour_list[(int)current_particles], 1.0); ++current_particles; // dispatch GUI updates to UI thread Dispatcher.Invoke(() => { aggregate_manager.Update(); DynamicParticleLabel.Content = "Particles: " + current_particles; }); } } }