Skip to content

Commit

Permalink
Merge pull request #73534 from CyrusNajmabadi/slowFar
Browse files Browse the repository at this point in the history
Batch FAR window update messages to lower refresh overhead.
  • Loading branch information
CyrusNajmabadi authored May 18, 2024
2 parents 07d428b + e48436f commit 61aa5c8
Showing 1 changed file with 14 additions and 1 deletion.
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

0 comments on commit 61aa5c8

Please sign in to comment.