Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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