private void OnFileSomethingChanged(string filename) { if (IsBlocked) { return; } var directory = Path.GetDirectoryName(filename); if (directory == null) { return; } directory = FileUtils.NormalizePath(directory); if (FileUtils.IsAffectedBy(_dir, filename) || string.Equals(directory, _dir, StringComparison.OrdinalIgnoreCase)) { _busyCreateConfigs.DoDelay(() => { if ((DateTime.Now - _lastSaved).TotalSeconds < 3d) { return; } CreateConfigs(); RescanPossibleIssues(); }, 300); if (FileUtils.ArePathsEqual(filename, PatchHelper.GetManifestFilename())) { _busyUpdateVersion.DoDelay(PatchHelper.Reload, 300); } } else if (Configs != null) { _busyCreateConfigs.DoDelay(() => { foreach (var item in Configs .SelectMany(x => x.Sections) .SelectMany(x => x) .OfType <PythonAppConfigPluginValue>()) { if (FileUtils.IsAffectedBy(filename, item.PluginsDirectory)) { item.ReloadPlugins(); } } }, 300); } if (FileUtils.ArePathsEqual(directory, AcRootDirectory.Instance.RequireValue)) { var name = Path.GetFileName(filename); if (string.Equals(name, "dwrite.dll", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "acs.exe", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "acs.pdb", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "changelog.txt", StringComparison.OrdinalIgnoreCase)) { RescanPossibleIssues(); } } }
private void OnWatcher(object sender, FileSystemEventArgs args) { if (_busy.Is) { _changedFilesToRescan.Add(args.FullPath); } else { _changedFilesToRescan.Clear(); _changedFilesToRescan.Add(args.FullPath); _busy.DoDelay(() => ScanMods(_changedFilesToRescan.ToArray()), 300); } }
private void ReloadLut() { _lutLoading.DoDelay(() => { try { if (string.IsNullOrWhiteSpace(LutName)) { LutGraphData = null; } else { var filename = Path.Combine(FileUtils.GetDocumentsCfgDirectory(), LutName); if (File.Exists(filename)) { var lut = new LutDataFile(filename).Values; lut.TransformSelf(x => new LutPoint(x.X * 100, x.Y * 100)); LutGraphData = new GraphData(lut); } else { LutGraphData = null; } } } catch (Exception e) { Logging.Warning(e); LutGraphData = null; } }, 50); }
private void RescanLuts() { _rescanning.DoDelay(() => { LutNames = new DirectoryInfo(FileUtils.GetDocumentsCfgDirectory()) .GetFiles("*.lut").Select(x => x.Name).ToArray(); }, 200); }
private static void OnQueueChanged(object o, NotifyCollectionChangedEventArgs a) { QueueChangedBusy.DoDelay(() => { if (ContentInstallationManager.Instance.Queue.Count == 0 && _dialog?.IsActive != true) { CloseInstallDialog(); } }, 100); }
private void OnDirectoryUpdate(string filename) { _busy.DoDelay(() => { if ((DateTime.Now - _lastSaved).TotalSeconds < 3d) { return; } CreateConfigs(); }, 300); }
private void OnConfigsValueChanged(object sender, EventArgs e) { if (_configs != null) { _configsSaveBusy.DoDelay(SaveConfigs, 500); } else { ((PythonAppConfigs)sender).ValueChanged -= OnConfigsValueChanged; } }
private void FileUpdate(object sender, FileSystemEventArgs e) { if (FileUtils.ArePathsEqual(e.FullPath, _resultFilename)) { _timer.IsEnabled = false; _processTcs?.TrySetResult(null); _busy.DoDelay(() => { _tcs?.TrySetResult(true); }, 500); } }
public async Task Test() { var busy = new Busy(); var value = 0; busy.DoDelay(() => value++, 10).Ignore(); busy.Do(() => value++); Assert.AreEqual(0, value); await Task.Delay(100); Assert.AreEqual(1, value); }
public void Remove(BlacklistItem item) { if (Items.Remove(item)) { _saveBusy.DoDelay(() => { try { _watcherBusy.Delay(500); File.WriteAllText(_filename, Items.Select(x => x.Guid).JoinToString("\n")); } catch (Exception e) { NonfatalError.NotifyBackground("Failed to save blacklist", e); } }, 500); } }
public void Door(bool open, TimeSpan delay) { _doorBusy.DoDelay(() => { try { _player.SetParam("state", open ? 1 : 0); _player.ToggleEvent(_prefix + "door", true); } catch (Exception e) { if (!_doorWarning) { _doorWarning = true; Logging.Warning(e); } } }, delay); }
private void OnConfigsValueChanged(object sender, EventArgs e) { _configsSaveBusy.DoDelay(SaveConfigs, 100); }
private void OnUpdate(object sender, FileSystemEventArgs fileSystemEventArgs) { _busy.DoDelay(() => Screenshots.ReplaceEverythingBy(GetUpdateEntries(_directory, _filter, Screenshots)), 300); }
private static void OnTaskAdded(object sender, EventArgs e) { TaskAddedBusy.DoDelay(ShowInstallDialog, 100); }
public void UpdateLater() { _updateLater.DoDelay(Update, 10); }
private void OnUpdate(object sender, FileSystemEventArgs fileSystemEventArgs) { _busy.DoDelay(() => Entries.ReplaceEverythingBy(GetUpdateEntries(_filter, Entries)), 300); }
private void OnWatcher(object sender, EventArgs args) { _busy.DoDelay(ScanMods, 300); }