private static void uploaderConfigWatcher_Changed(object sender, FileSystemEventArgs e) { if (!uploaderConfigWatcherTimer.IsDuplicateEvent(e.FullPath)) { Action onCompleted = () => ReloadUploadersConfig(e.FullPath); Helpers.WaitWhileAsync(() => Helpers.IsFileLocked(e.FullPath), 250, 5000, onCompleted, 1000); uploaderConfigWatcherTimer = new WatchFolderDuplicateEventTimer(e.FullPath); } }
private static void uploaderConfigWatcher_Changed(object sender, FileSystemEventArgs e) { if (!uploaderConfigWatcherTimer.IsDuplicateEvent(e.FullPath)) { SynchronizationContext context = SynchronizationContext.Current ?? new SynchronizationContext(); Action onCompleted = () => context.Post(state => ReloadUploadersConfig(e.FullPath), null); Helpers.WaitWhileAsync(() => Helpers.IsFileLocked(e.FullPath), 250, 5000, onCompleted, 1000); uploaderConfigWatcherTimer = new WatchFolderDuplicateEventTimer(e.FullPath); } }
public static void ConfigureUploadersConfigWatcher() { if (Program.Settings.DetectUploaderConfigFileChanges && uploaderConfigWatcher == null) { uploaderConfigWatcher = new FileSystemWatcher(Path.GetDirectoryName(Program.UploadersConfigFilePath), Path.GetFileName(Program.UploadersConfigFilePath)); uploaderConfigWatcher.Changed += uploaderConfigWatcher_Changed; uploaderConfigWatcherTimer = new WatchFolderDuplicateEventTimer(Program.UploadersConfigFilePath); uploaderConfigWatcher.EnableRaisingEvents = true; } else if (uploaderConfigWatcher != null) { uploaderConfigWatcher.Dispose(); uploaderConfigWatcher = null; } }