locked
Async and await RRS feed

  • Question

  •  public void DownLoad(object sender, HtmlDocumentLoadCompleted e)
        {

                if (e.Error == null)
                {
                    HtmlDocument doc =  e.Document;

                    if (doc != null)
                    {

                        var userprofile = doc.DocumentNode.SelectSingleNode("//div[@class = 'ui-large-content']");
                        App.Data2 =   userprofile.InnerText;
                        App.savecontent(App.Data2);



                    }
                }

    how to convert this function as a task with async and await..

    help pls ...i need to use await for the App.Data2 = userprofile.innertext;

    this one is incomplete wen i tried to execute as a normal function ...it comes after reloading the page...i need it without reloading it ....:/

                                                                                       
    Monday, March 31, 2014 3:28 AM

Answers

  • You'll have to show the code snippet that is skipping

    http://pauliom.wordpress.com

    Tuesday, April 1, 2014 7:03 AM

All replies

  • replace void with task and you are done.
    Monday, March 31, 2014 8:14 AM
  • Well, it doesn't look like you've got any async code to await??


    http://pauliom.wordpress.com

    Monday, March 31, 2014 9:50 AM
  • In this I'm using the html agilitypack and now whenever I call this function this gets the data from the website .But, since this is a normal function it skips to the next line without getting the content from net(" App.Data2 =   userprofile.InnerText;") .after if I press a refresh button which I made for this to re call that function then I get the data .I need to await this one so that the data comes automatically whenever its ready ..do u have any idea about it sir?
    Tuesday, April 1, 2014 5:22 AM
  • You'll have to show the code snippet that is skipping

    http://pauliom.wordpress.com

    Tuesday, April 1, 2014 7:03 AM
  • can I send u the project file sir . It will be easier to make it finish and I will be thankful to you ..this may guide me in my further projects .
    Tuesday, April 1, 2014 7:22 AM