/// <summary> /// Manage workers for tile groups for days where emerging tiles are no longer tracked. /// </summary> /// <param name="groups"></param> /// <remarks> /// The function manages workers for tile groups on days that are beyond some threshold for monitoring emerging tiles. If this group does /// not yet have a monitor a worker that only iterates existing tiles is created. If this group has an emerging tile worker because it was /// below the threshold when originally created that emerging worker is halted. /// </remarks> private void UpdateHistorialTileGroupWorkers(IEnumerable<TileGroup> groups) { foreach (var tileGroup in groups) { TileGroupEmergingWorker worker; if (_discoveryWorkers.TryGetValue(tileGroup, out worker)) { if (worker.DiscontinueWatching()) { _discoveryWorkers.TryRemove(tileGroup, out worker); Trace.TraceInformation(String.Format("\t\tHalted emerging Tile Group worker for {0}", tileGroup.FullPath)); worker.Dispose(); } } else { Trace.TraceInformation(String.Format("\t\tNot starting emerging Tile Group worker for {0}", tileGroup.FullPath)); TileGroupExistingWorker independentExistingWorker; if (!_existingOnlyWorkers.TryGetValue(tileGroup, out independentExistingWorker)) { independentExistingWorker = new TileGroupExistingWorker(tileGroup, _existingTileQueue); independentExistingWorker.ExpectedChannelCount = Model.ExpectedChannelCount; independentExistingWorker.MinTiffFileSize = Model.MinTiffFileSize; if (_existingOnlyWorkers.TryAdd(tileGroup, independentExistingWorker)) { Trace.TraceInformation(String.Format("Iterating existing tiles in {0}.", tileGroup.FullPath)); // TODO Make cancellable for Stop in the middle. independentExistingWorker.Run(); } else { Trace.TraceInformation(String.Format("Skipping iteration of existing tiles in {0}. This group has already been scanned.", tileGroup.FullPath)); } } else { Trace.TraceInformation(String.Format("Skipping iteration of existing tiles in {0}. This group has already been scanned.", tileGroup.FullPath)); } } } }
protected override bool QueueFiles() { _debounceTimer.Enabled = true; _watcher.EnableRaisingEvents = true; _existingWorker = new TileGroupExistingWorker(Group, _existingQueue); _existingWorker.ExpectedChannelCount = this.ExpectedChannelCount; _existingWorker.MinTiffFileSize = this.MinTiffFileSize; _existingWorker.Run(); return false; }