public static void InvalidateFeatures() { _featuresInvalidatedBusy.Delay(() => { _customVideoModes = null; FeaturesInvalidated?.Invoke(null, EventArgs.Empty); }, 100); }
public static async Task Delay([NotNull] this Busy busy, Func <Task> a, TimeSpan delay, bool force = false) { using (busy.Set()) { await a(); } busy.Delay(delay, force).Ignore(); }
public static async Task Delay([NotNull] this Busy busy, Func <Task> a, int millisecondsDelay, bool force = false) { using (busy.Set()) { await a(); } busy.Delay(millisecondsDelay, force).Ignore(); }
public static void Delay([NotNull] this Busy busy, Action a, TimeSpan delay, bool force = false) { using (busy.Set()) { a(); } busy.Delay(delay, force).Ignore(); }
public static void Delay([NotNull] this Busy busy, Action a, int millisecondsDelay, bool force = false) { using (busy.Set()) { a(); } busy.Delay(millisecondsDelay, force).Ignore(); }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(RaceResultsObject.IsDeleting)) { _busy.Delay(1000); } if (e.PropertyName == nameof(RaceResultsObject.IsDeleted)) { Entries.Remove((RaceResultsObject)sender); } }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Screenshot.IsDeleting)) { _busy.Delay(1000); } if (e.PropertyName == nameof(Screenshot.IsDeleted)) { Screenshots.Remove((Screenshot)sender); } }
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 Task EnableAsync([NotNull] GenericMod mod, IProgress <Tuple <string, double?> > progress = null, CancellationToken cancellation = default) { if (mod.IsEnabled) { throw new InformativeException("Can’t enable mod", "Mod is already enabled."); } return(_busy.Delay(() => Task.Run(() => _operationBusy.Do(() => { Debug($"Enabling {mod.DisplayName}…"); var iniFile = new IniFile(ConfigFilename, IniFileMode.SquareBracketsWithin); iniFile["MODS"].Set(mod.DisplayName, int.MaxValue); var dependancies = iniFile["DEPENDANCIES"]; foreach (var dependant in CheckConflicts(mod).Select(x => x.ModName).Distinct()) { var current = dependancies.GetGenericModDependancies(dependant); if (current?.ArrayContains(mod.DisplayName) == true) { continue; } dependancies.SetGenericModDependancies(dependant, (current ?? new string[0]).Append(mod.DisplayName)); } SaveApplyOrder(iniFile, true); var installationLog = GetInstallationLogFilename(ModsDirectory, mod.DisplayName); Debug($"Installation log: {installationLog}"); if (File.Exists(installationLog)) { throw new InformativeException("Can’t enable mod", "Mod is already enabled."); } using (var writer = new StreamWriter(installationLog, false)) { var files = mod.Files; for (var i = 0; i < files.Length; i++) { var file = files[i]; if (file.RelativeName.EndsWith(".jsgme", StringComparison.OrdinalIgnoreCase)) { Debug($"File, src={file.Source}, ignore as description"); continue; } Debug($"File, src={file.Source}, dst={file.Destination})"); if (cancellation.IsCancellationRequested) { return; } progress?.Report(Tuple.Create(file.RelativeName, (double?)(0.001 + 0.998 * i / files.Length))); try { if (File.Exists(file.Destination)) { Debug($"Already exists, moving to {file.Backup}"); FileUtils.EnsureFileDirectoryExists(file.Backup); File.Move(file.Destination, file.Backup); } if (file.Source != null) { FileUtils.EnsureFileDirectoryExists(file.Destination); Debug($"Copying to {file.Destination}"); if (_useHardLinks) { FileUtils.HardLinkOrCopy(file.Source, file.Destination, true); } else { File.Copy(file.Source, file.Destination, true); } } writer.WriteLine(file.RelativeName); } catch (Exception e) { Logging.Warning(e); } } } })), 300, true)); }