Skip to content

Commit

Permalink
Search Cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
r-Larch committed Jun 18, 2020
1 parent fc55d1a commit 315c1f8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/GelbeSeitenSpider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -53,7 +52,7 @@ protected override async Task Search(string search, CancellationToken token)
Progress = 0;

var document = await GetPage(search, token: token);
AddResults(GetListItems(document, token).ToArray());
AddResults(GetListItems(document).ToArray());
PageCount = GetPageCount(document);

var page = 1;
Expand All @@ -63,7 +62,7 @@ protected override async Task Search(string search, CancellationToken token)
await Task.WhenAll(
batch.Select(async pageNum => {
var document = await GetPage(search, pageNum, token);
AddResults(GetListItems(document, token).ToArray());
AddResults(GetListItems(document).ToArray());

Interlocked.Increment(ref page);
Progress = (int) ((page / (double) PageCount) * 100d);
Expand Down Expand Up @@ -116,7 +115,7 @@ private static int GetPageCount(IDocument listPage)
}


private IEnumerable<SearchResult> GetListItems(IDocument listPage, CancellationToken token)
private IEnumerable<SearchResult> GetListItems(IDocument listPage)
{
var items = listPage.QuerySelectorAll("#gs_treffer .mod-Treffer");

Expand Down

0 comments on commit 315c1f8

Please sign in to comment.