private void TextBoxTextChanged(object sender, EventArgs e) { if (!_ignoreTextBoxChange) { _speciesChangeDebouncer.Debounce(300, FilterListWithUnselectedText, Dispatcher.CurrentDispatcher); } }
private void Input_ValueChanged(object sender, EventArgs e) { if (WeightingsChanged != null) { _valueChangedDebouncer.Debounce(200, WeightingsChanged, Dispatcher.CurrentDispatcher); } }
public void NullActionIsNotAllowedForDebounce() { Assert.Throws <ArgumentNullException>(() => { Debouncer.Debounce(null); }); }
private void SendChangedMessageDebounced() { _debouncer.Debounce(25, delegate { DoFinal(); SendChangedMessage(); }); }
public MainWindow() { InitializeComponent(); throttler = Throttler.Throttle <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(throttled, now)), TimeSpan.FromSeconds(1)); debouncerTrailing = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedTrailing, now)), TimeSpan.FromSeconds(1), false, true); debouncerLeading = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedLeading, now)), TimeSpan.FromSeconds(1), true, false); debouncerBoth = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedBoth, now)), TimeSpan.FromSeconds(1), true, true); }
private void OnModelsChanged(object sender, FileSystemEventArgs e) { Task.Factory.StartNew(() => { // Give time to the compiled file to be usable Task.Delay(300); this.assemblyProcessor.Process(e.FullPath); debouncer.Debounce(EchoListening, 2000); }); }
private void nudLevel_ValueChanged(object sender, EventArgs e) { _debouncer.Debounce(300, () => { UpdateFirstFeedingWaiting(); UpdateTamingData(); }, Dispatcher.CurrentDispatcher); }
static void Main(string[] args) { Debouncer debouncer = new Debouncer(); for (int i = 0; i < 50; i++) { debouncer.Debounce("Scope", "UniqueSignature", "Requestor", () => { System.Console.WriteLine($"PASSED {i}"); }); } System.Console.ReadLine(); }
private void SeekBarOnProgressChanged(object sender, SeekBar.ProgressChangedEventArgs e) { if (!e.FromUser) { return; } Debouncer.Debounce(nameof(AudioApplicationViewHolder) + nameof(SeekBarOnProgressChanged) + _id, () => { _progress = e.Progress; RaiseDataUpdateRequired(AbsoluteAdapterPosition); }, TimeSpan.FromSeconds(1)); }
private void DecideTest(int debounceInterval = 700) { StatusText = ""; StatusResult = false; var allin = this[nameof(ApiName)] == null && this[nameof(ApiKey)] == null && this[nameof(ApiSecret)] == null && this[nameof(ApiExtra1)] == null; if (!allin) { return; } _debouncer.Debounce(debounceInterval, o => CheckKeys()); }
internal void startGuarding() { fixSubscriptions(); DebouncedAction onSubscriptionFileChanged = Debouncer.Debounce(() => { Console.WriteLine("\nChange detected, fixing subscriptions..."); fixSubscriptions(); }, TimeSpan.FromMilliseconds(50)); subscriptionConfigurationFileWatcher.Changed += delegate { onSubscriptionFileChanged.Run(); }; folderWatcher.Created += delegate { onSubscriptionFileChanged.Run(); }; folderWatcher.Renamed += delegate { onSubscriptionFileChanged.Run(); }; subscriptionConfigurationFileWatcher.EnableRaisingEvents = true; folderWatcher.EnableRaisingEvents = true; Console.WriteLine("Waiting for subscription changes..."); }
private void SeekBarOnProgressChanged(object sender, SeekBar.ProgressChangedEventArgs e) { const int step = 5; var progress = e.Progress; progress = progress / step; progress = progress * step; _textView.Text = $"Master volume: {progress}"; _seekBar.SetProgress(progress, true); Log.Info("Setting master volume to {Value} FromUser: {FromUser}", progress, e.FromUser); if (e.FromUser) { Debouncer.Debounce(nameof(AudioFragment) + nameof(SeekBarOnProgressChanged), async() => { await _agent.DesktopClient.SetMasterVolumeAsync(TimeSpan.FromSeconds(5), progress); ToastHelper.Display("Volume updated", ToastLength.Short); }, TimeSpan.FromSeconds(2)); } }
public MainWindow() { InitializeComponent(); registryKey = Registry.CurrentUser.CreateSubKey(@"Software\DakarMapper", true); string?previousWindowPosition = (string?)registryKey.GetValue(WINDOW_POSITION_REGISTRY_NAME); if (previousWindowPosition != null) { string[] coordinates = previousWindowPosition.Split(','); Left = Convert.ToDouble(coordinates[0]); Top = Convert.ToDouble(coordinates[1]); Width = Convert.ToDouble(coordinates[2]); Height = Convert.ToDouble(coordinates[3]); } DebouncedAction onWindowMoved = Debouncer.Debounce(() => Dispatcher.Invoke(() => registryKey.SetValue(WINDOW_POSITION_REGISTRY_NAME, string.Join(",", new[] { Left, Top, Width, Height }))), TimeSpan.FromMilliseconds(500)); LocationChanged += delegate { onWindowMoved.Run(); }; SizeChanged += delegate { onWindowMoved.Run(); }; }
private void Overview_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) { _dispatcher.Debounce(10, o => Debounced(o as MouseWheelEventArgs), e); }
public static IApplicationBuilder UseAdminPage(this IApplicationBuilder app, IConfiguration configuration, ILoggerFactory loggerFactory) { var cubesConfig = configuration.GetCubesConfiguration(); var zipPath = configuration.GetCubesConfiguration().AdminPath; var logger = loggerFactory.CreateLogger <Content>(); if (!File.Exists(zipPath)) { logger.LogWarning($"Could not load 'Cubes Management' application from path: {zipPath}"); return(app); } else { logger.LogInformation("Serving 'Cubes Management' from {contentPath}, request path '{requestPath}'.", zipPath, "/admin"); } // Currently Compressed FileProvider seems to be broken! var useCompressedFileProvider = false; IFileProvider fileProvider; if (useCompressedFileProvider) { fileProvider = new CompressedFileProvider(zipPath); // Inform for changes on CompressedFileProvider var fileName = Path.GetFileName(zipPath); var debouncer = new Debouncer(); void call() => logger.LogInformation("File {cubesAdminPath} changed, 'Cubes Management' should be reloaded!", fileName); ChangeToken.OnChange( () => fileProvider.Watch(fileName), () => debouncer.Debounce(call)); } else { var tempFolder = Path.Combine(cubesConfig.TempFolder, "CubesManagement"); DeployZipOnTemp(tempFolder, zipPath); fileProvider = new PhysicalFileProvider(tempFolder); // Setup file changes mechanism for zip file var fileName = Path.GetFileName(zipPath); var pfp = new PhysicalFileProvider(Path.GetDirectoryName(zipPath)); if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { pfp.UsePollingFileWatcher = true; } var debouncer = new Debouncer(); void call() { DeployZipOnTemp(tempFolder, zipPath); logger.LogInformation($"File {fileName} changed, 'Cubes Management' should be reloaded!"); } ChangeToken.OnChange( () => pfp.Watch(fileName), () => debouncer.Debounce(call)); } var options = new FileServerOptions { FileProvider = fileProvider, RequestPath = "", EnableDefaultFiles = true, }; options.DefaultFilesOptions.DefaultFileNames.Clear(); options.DefaultFilesOptions.DefaultFileNames.Add("index.html"); app.Map(new PathString("/admin"), builder => { builder.UseFileServer(options); builder.Use(async(context, next) => { await next(); var fullRequest = context.Request.PathBase.Value + context.Request.Path.Value; if (context.Response.StatusCode == 404 && !Path.HasExtension(fullRequest) && !Directory.Exists(fullRequest)) { // Fall back to SPA entry point context.Response.StatusCode = 200; if (useCompressedFileProvider) { await fileProvider.GetFileInfo("index.html") .CreateReadStream() .CopyToAsync(context.Response.Body); } else { await context.Response .WriteAsync(File.ReadAllText(fileProvider.GetFileInfo("index.html").PhysicalPath)); } } }); }); return(app); }
public void Update() { _debouncer.Debounce(500, o => UpdateDebounced()); }
private static async Task Main(string[] args) { StartAnalytics(); AnalyticsApi.UserAgent = EditorName = GetEditorNameByArgs(args); AnalyticsApi.TrackEvent("SessionStart", "Session Start", extraValues: new { sc = "start" }); AnalyticsApi.TrackEvent("ServerStart", "Started LSP Server", extraValues: new { sc = "start" }); if (args.Any(a => a.ToLower().Equals("-d"))) { while (!Debugger.IsAttached) { await Task.Delay(100); } } ILanguageServer server = null; server = await LanguageServer.From(options => { options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging(c => c.AddLanguageProtocolLogging()) .WithHandler <TextDocumentHandler>() .WithHandler <TextHoverHandler>(); options.OnRequest <object, int>("insight/inspectionsCount", _ => Task.FromResult(WorkspaceManager.Instance.InspectionsManager.CodeInspections.Count)); var debouncedParseRange = Debouncer.Debounce <SkriptFile>(file => file.NotifyVisibleNodesRangeChanged(), TimeSpan.FromMilliseconds(500)); options.OnNotification <ViewportChangedParams>("insight/viewportRangeChanged", e => { var file = WorkspaceManager.CurrentWorkspace.WorkspaceManager.GetOrCreateByUri(e.Uri.ToUri()); if (file == null) { return; } file.VisibleRanges = e.Ranges; debouncedParseRange.Run(file); }); options.OnNotification("insight/notifySupportsExtendedCapabilities", async() => { if (WorkspaceManager.CurrentHost == null) { return; } var sendRequest = WorkspaceManager.CurrentHost.SendRawRequest <ExtendedHostCapabilities>( "insight/queryExtendedCapabilities"); if (sendRequest != null) { WorkspaceManager.CurrentHost.ExtendedCapabilities = await sendRequest; } }); }); WorkspaceManager.CurrentHost = new LspSkriptInsightHost(server); WorkspaceManager.CurrentHost.LogInfo("SkriptInsight loaded successfully."); #pragma warning disable 4014 Task.Run(() => StartDiscordRichPresence(WorkspaceManager.CurrentWorkspace)); #pragma warning restore 4014 await server.WaitForExit; DiscordRpcClient?.Dispose(); AnalyticsApi.CancellationToken.Cancel(); AnalyticsApi.TrackEvent("ServerStop", "Stopped LSP Server"); AnalyticsApi.TrackEvent("SessionStop", "Session Stop", extraValues: new { sc = "stop" }); }
private void TbModFilter_TextChanged(object sender, EventArgs e) { _modFilterDebouncer.Debounce(300, FilterMods, Dispatcher.CurrentDispatcher); }
private void TextBoxFilterTextChanged(object sender, EventArgs e) { _filterDebouncer.Debounce(TextBoxFilter.Text == string.Empty ? 0 : 500, DisplayFilteredCreatureList, Dispatcher.CurrentDispatcher); }
public void NullActionIsNotAllowedForDebounce() { Debouncer.Debounce(null); }
/// <summary> /// Shows a preview of the white-threshold if a screenshot is displayed /// </summary> /// <param name="value">The white-threshold. -1 disables the preview</param> private void ShowPreviewWhiteThreshold(int value) { _redrawingDebouncer.Debounce(500, RedrawScreenshot, Dispatcher.CurrentDispatcher, (-1, false, value, Rectangle.Empty)); }