/// <summary> /// Contructor to initialize the worker. /// </summary> /// <param name="workQueue">Work queue share amon workers.</param> /// <param name="elevationMap">Elevation map</param> /// <param name="sumator">Sumator instance</param> /// <param name="parent">Work manager</param> public VisualMagnitudeWorker(ref ConcurrentQueue <SpatialUtils.ViewpointProps> workQueue, ref GeoMap elevationMap, ref Sumator sumator, WorkManager parent) { spatialUtils = new SpatialUtils(ref elevationMap); this.workQueue = workQueue; this.elevationMap = elevationMap; this.sumator = sumator; this.parent = parent; }
/// <summary> /// Start calculationg the visual magnitude. /// </summary> /// <param name="elevationMap">Elevation map</param> public void StartWorking(ref GeoMap elevationMap) { sumator = new Sumator(elevationMap.GetLength(0), elevationMap.GetLength(1)); sumator.Start(); startingQueueSize = workQueue.Count; runningThreads = threadCount; for (int i = 0; i < threadCount; i++) { VisualMagnitudeWorker worker = new VisualMagnitudeWorker(ref workQueue, ref elevationMap, ref sumator, this); Thread thread = new Thread(worker.Start); threads[i] = thread; thread.Start(); } }