public void RemoveAndStop(PipelineMapping mapping) { var monitor = monitors.Where(m => m.Mapping == mapping).SingleOrDefault(); if (monitor == null) { throw new InvalidOperationException("Monitor with mapping not found"); } monitor.Stop(); monitors.Remove(monitor); }
public PipelineMonitor(FileNotificationQueue queue, PipelineMapping mapping) { this.queue = queue; this.Mapping = mapping; watcher = new FileSystemWatcher(mapping.InputDirectory); watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.DirectoryName; watcher.Changed += new FileSystemEventHandler(CreatedOrChanged); watcher.Renamed += new RenamedEventHandler(Renamed); watcher.Created += new FileSystemEventHandler(CreatedOrChanged); }