public static void RegisterReloadNotification(Type type, EventHandler delegateMethod, bool allowMultiple) { List <EventHandler> delegateMethods; using (reloadDelegatesResourceLock.WaitToWrite()) { if (!allowMultiple || !reloadTypeDelegates.TryGetValue(type, out delegateMethods)) { delegateMethods = new List <EventHandler>(); delegateMethods.Add(delegateMethod); reloadTypeDelegates[type] = delegateMethods; } else { delegateMethods.Add(delegateMethod); } } }
private void scareCrow_Changed(object sender, FileSystemEventArgs e) { try { string fileName = e.Name.ToLower(); using (fileLoadResourceLock.WaitToWrite()) { if (pendingFileReloads.Contains(fileName) || !ContainsFile(fileName)) { return; } pendingFileReloads.Add(fileName); } CountdownTimer timer = new CountdownTimer(); timer.BeginCountdown(CHANGE_FILE_DELAY, DelayedProcessFileChanged, fileName); } catch (Exception ex) { logger.HandleException(ex, "FileWatcher"); } }