/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="delegateMethod">delegateMethod(string filePath,Empty), filePath is in lower case</param> public void AddFile(string fileName, EventHandler delegateMethod) { using (filesLock.AcquireWriterLock()) { if (!files.ContainsKey(fileName)) { files.AddOrUpdate(fileName, delegateMethod); } } }
private void scareCrow_Changed(object sender, FileSystemEventArgs e) { try { string fileName = e.Name; using (fileLoadResourceLock.AcquireWriterLock()) { if (pendingFileReloads.Contains(fileName) || !ContainsFile(fileName)) { return; } pendingFileReloads.Add(fileName); } CountdownTimer timer = new CountdownTimer(); timer.BeginCountdown(ConfigurationConst.CHANGE_FILE_DELAY, DelayedProcessFileChanged, fileName); } catch (Exception ex) { _logger.LogError(ex, "FileWatcher Error"); } }