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

Batch FAR window update messages to lower refresh overhead. #73534

Merged
merged 3 commits into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private abstract class AbstractTableDataSourceFindUsagesContext :
protected readonly IWpfTableControl2 TableControl;

private readonly AsyncBatchingWorkQueue<(int current, int maximum)> _progressQueue;
private readonly AsyncBatchingWorkQueue _notifyQueue;

protected readonly object Gate = new();

Expand Down Expand Up @@ -163,6 +164,18 @@ protected AbstractTableDataSourceFindUsagesContext(
this.UpdateTableProgressAsync,
presenter._asyncListener,
CancellationTokenSource.Token);

// Similarly, updating the actual FAR window can be quite expensive (especially when there are thousands of
// results). To limit the amount of work we do, we'll only update the window every 250ms.
_notifyQueue = new AsyncBatchingWorkQueue(
DelayTimeSpan.Short,
cancellationToken =>
{
_tableDataSink.FactorySnapshotChanged(this);
return ValueTaskFactory.CompletedTask;
},
presenter._asyncListener,
CancellationTokenSource.Token);
}

protected abstract Task OnCompletedAsyncWorkerAsync(CancellationToken cancellationToken);
Expand Down Expand Up @@ -203,7 +216,7 @@ private static ImmutableArray<string> SelectCustomColumnsToInclude(ImmutableArra
}

protected void NotifyChange()
=> _tableDataSink.FactorySnapshotChanged(this);
=> _notifyQueue.AddWork();

private void OnFindReferencesWindowClosed(object sender, EventArgs e)
{
Expand Down
Loading