Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: How to check HtmlWeb.LoadAsync finished

$
0
0

I have a class in Viewmodel folder that using HtmlWeb.LoadAsync to get data from web:

 

public void GetContent(int index)
        {
            //get content
            HtmlWeb.LoadAsync(Magazines[index].Url, (s, args) =>
            {

              ....

             this.Magazines[index].ContentNode = contentNode.InnerHtml;
            });

}

 

Then I want to get the Magazines[index].contentNode in detailview.xaml like this:

protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string selectedIndex = "";
           
            if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
            {
              index = int.Parse(selectedIndex);
              App.MagazineViewModel.GetContent(index);
              String content = App.MagazineViewModel.Magazines[index].ContentNode;
              DetailBrser.NavigateToString(
                 "<html><head><meta name='viewport' content='width=570, user-scalable=yes' /></head><body>"
                 + HtmlHelper.EncodeUnicode(content)
                 + "</body></html>"
                 );
            }

But the problem is the loadAsync method has not finished yet, so App.MagazineViewModel.Magazines[index].contentNode is empty. that also make content empty.  so how can I check App.MagazineViewModel.GetContent(index) finish in detailview.xaml then set the content string. Or any other idea for this.


Viewing all articles
Browse latest Browse all 655

Trending Articles