Add manually check updates option

1. manually check updates
2. refactoring get http request to use async
3. remove some generic exception catch
4. remove unused code
This commit is contained in:
bao-qian
2016-05-09 02:32:47 +01:00
parent 373da78b7b
commit 6ac33b0568
13 changed files with 209 additions and 147 deletions

View File

@@ -85,10 +85,10 @@ namespace Wox.Plugin.WebSearch
if (_settings.EnableWebSearchSuggestion)
{
const int waittime = 300;
var task = Task.Run(() =>
var task = Task.Run(async () =>
{
results.AddRange(ResultsFromSuggestions(keyword, subtitle, webSearch));
var suggestions = await Suggestions(keyword, subtitle, webSearch);
results.AddRange(suggestions);
}, _updateToken);
if (!task.Wait(waittime))
@@ -102,12 +102,12 @@ namespace Wox.Plugin.WebSearch
}
}
private IEnumerable<Result> ResultsFromSuggestions(string keyword, string subtitle, WebSearch webSearch)
private async Task<IEnumerable<Result>> Suggestions(string keyword, string subtitle, WebSearch webSearch)
{
var source = SuggestionSource.GetSuggestionSource(_settings.WebSearchSuggestionSource, Context);
var suggestions = source?.GetSuggestions(keyword);
if (suggestions != null)
if (source != null)
{
var suggestions = await source.GetSuggestions(keyword);
var resultsFromSuggestion = suggestions.Select(o => new Result
{
Title = o,