Replace DelayInvoke with Task + Async

This commit is contained in:
bao-qian
2016-01-06 06:31:17 +00:00
parent b78e0144de
commit 1a8efdbf2c
6 changed files with 88 additions and 137 deletions

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -484,13 +485,14 @@ namespace Wox
}
}
_lastQuery = query;
Dispatcher.DelayInvoke("ShowProgressbar", () =>
Dispatcher.InvokeAsync(async () =>
{
await Task.Delay(150);
if (!string.IsNullOrEmpty(query.RawQuery) && query.RawQuery == _lastQuery.RawQuery && !_queryHasReturn)
{
StartProgress();
}
}, TimeSpan.FromMilliseconds(150));
});
PluginManager.QueryForAllPlugins(query);
}
StopProgress();
@@ -829,6 +831,7 @@ namespace Wox
private void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
{
Thread.Sleep(3000);
_queryHasReturn = true;
progressBar.Dispatcher.Invoke(new Action(StopProgress));