Skip to content

[Issue #179]: Adds System.Threading.Timer for aggregate change delay.#182

Open
Zettersten wants to merge 1 commit intoJeringTech:masterfrom
Zettersten:feature/issue-179/adds-delay-to-file-watcher
Open

[Issue #179]: Adds System.Threading.Timer for aggregate change delay.#182
Zettersten wants to merge 1 commit intoJeringTech:masterfrom
Zettersten:feature/issue-179/adds-delay-to-file-watcher

Conversation

@Zettersten
Copy link

No description provided.

@JeremyTCD
Copy link
Member

My bad, when I was looking through your changes I realized that I'd already written debouncing logic:

internal virtual async Task InternalFileHandlerCoreAsync(string path)
{
if (_debugLoggingEnabled)
{
_logger.LogDebug(string.Format(Strings.LogDebug_InternalFileChangedHandlerCalled, path));
}
if (_fileChanged == null)
{
return; // No listeners
}
// Debounce by cancelling until an invocation occurs with no subsequent invocations for 1ms
CancellationTokenSource cancellationTokenSource = CancelExistingAndGetNewCancellationTokenSource();
try
{
CancellationToken cancellationToken = cancellationTokenSource.Token;
await Task.Delay(1).ConfigureAwait(false);
if (cancellationToken.IsCancellationRequested)
{
if (_debugLoggingEnabled)
{
_logger.LogDebug(string.Format(Strings.LogDebug_InternalFileChangedHandlerCallDebounced, path));
}
return;
}
// Invoke handlers
if (_infoLoggingEnabled)
{
_logger.LogInformation(string.Format(Strings.LogInformation_InvokingRegisteredFileChangedHandlers, path));
}
_fileChanged();
}
finally
{
DisposeAndRemoveCancellationTokenSource(cancellationTokenSource);
}
}

We were debouncing, but with a fixed, small debounce time of 1ms.

Would you like to amend your PR to add an option for configuring that duration? Changes to OutOfProcessNodeJSService no longer necessary.

The option name/comments should indicate that we are debouncing, not aggregating changes over a set time period. Name should be something like "DebounceDuration".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants