public static void ParseRecommends(string html, Action<List<Recommend>> finished)
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler((sender, e) =>
{
List<Recommend> allRecommends = new List<Recommend>();
HtmlDocument hDoc = new HtmlDocument();
hDoc.LoadHtml(html);
var tableRows = hDoc.DocumentNode.SelectNodes(Constants.Instance.XPATH_GAME_SHOW_RESULT);
foreach (var node in tableRows)
{
var results = ChildElementsInTableRow(node);
if (results.Count == Constants.Instance.COUNT_GAME_SHOW_RESULT_COLUMNS)
{
var rec = RecommendFromStrings(results);
if (IsValidRecommend(rec))
{
allRecommends.Add(rec);
}
}
}
finished(allRecommends);
});
bw.RunWorkerAsync();
}