Reduce batch time to speed up view update

change selected index update place to fix not first selection issue
This commit is contained in:
弘韬 张 2020-11-13 13:41:59 +08:00
parent f51d2c57c7
commit 4b2abfc708
2 changed files with 7 additions and 2 deletions

View file

@ -111,7 +111,7 @@ namespace Flow.Launcher.ViewModel
while (true)
{
List<ResultsForUpdate> queue = new List<ResultsForUpdate>() { _resultsUpdateQueue.Take() };
await Task.Delay(50);
await Task.Delay(30);
while (_resultsUpdateQueue.TryTake(out var resultsForUpdate))
{

View file

@ -158,6 +158,11 @@ namespace Flow.Launcher.ViewModel
public void AddResults(IEnumerable<ResultsForUpdate> resultsForUpdates)
{
var newResults = NewResults(resultsForUpdates);
// https://social.msdn.microsoft.com/Forums/vstudio/en-US/5ff71969-f183-4744-909d-50f7cd414954/binding-a-tabcontrols-selectedindex-not-working?forum=wpf
// fix selected index flow
SelectedIndex = 0;
lock (_collectionLock)
{
Results.Update(newResults);
@ -167,7 +172,6 @@ namespace Flow.Launcher.ViewModel
{
case Visibility.Collapsed when Results.Count > 0:
Margin = new Thickness { Top = 8 };
SelectedIndex = 0;
Visbility = Visibility.Visible;
break;
case Visibility.Visible when Results.Count == 0:
@ -175,6 +179,7 @@ namespace Flow.Launcher.ViewModel
Visbility = Visibility.Collapsed;
break;
}
}