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 Button_Click(object sender, RoutedEventArgs e) { string now = GetNow(); UpdateLabelContent(original, now); throttler.Run(now); debouncerTrailing.Run(now); debouncerLeading.Run(now); debouncerBoth.Run(now); }
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(); }; }
public GitExtensionsHandlerImpl(WindowOpeningListener windowOpeningListener) { _onWindowClosedThrottled = Throttler.Throttle((bool firstRun) => onWindowClosed(firstRun), TimeSpan.FromSeconds(2)); timer = new Timer { AutoReset = true, Interval = 200 }; timer.Elapsed += findCommitWindows; windowOpeningListener.windowOpened += onWindowOpened; Automation.AddAutomationEventHandler(WindowPattern.WindowClosedEvent, AutomationElement.RootElement, TreeScope.Subtree, onWindowClosedThrottled); _onWindowClosedThrottled.Run(true); LOGGER.Trace("Waiting for Git Extensions commit window"); }
private void onWindowClosedThrottled(object?sender = null, AutomationEventArgs?e = null) { _onWindowClosedThrottled.Run(false); }