private void OnChanged(object sender, FileSystemEventArgs e) { if (File.GetAttributes(e.FullPath).HasFlag(FileAttributes.Directory)) { return; } List <string> files = FilesToBeScanned.ToList(); foreach (var item in files) { if (item.Equals(e.FullPath)) { return; } } FilesToBeScanned.Enqueue(e.FullPath); if (!IsScanning) { IsScanning = true; Thread thread1 = new Thread(ScanFiles); Thread thread2 = new Thread(ScanZipFiles); thread1.Start(); thread2.Start(); } Console.WriteLine($"Changed: {e.FullPath}, Type: {e.ChangeType}"); }
override protected void ScanFiles() { while (task.IsActive) { if (FilesToBeScanned.Count > 0) { string path = FilesToBeScanned.Dequeue(); //если файл оказался исполняемым, то мы мы проверяем его сигнатуру if (ScanFileStream(GetFileStream(path), path)) { CheckFileStream(GetFileStream(path), path); } } else { Thread.Sleep(1000); } } //IsScanning = false; }