I'm trying to apply thread s in a method which sets some properties. but after applying threading the method stops setting the values. My code :
Class Page.cs
public int numOfResults { get; private set; }
public int perPage { get; private set; }
public int pageCount  { get; private set; }
public void pageResults()
{
    HtmlWeb htmlWeb = new HtmlWeb();
    HtmlDocument document = htmlWeb.Load(this.url);
    var totalResults = document.DocumentNode
                               .Descendants("div")
                               .Where(x => x.Attributes.Contains("class") &&
                                           x.Attributes["class"].Value.Contains("result-totals"));
    string totalPages = string.Empty;
    foreach (var result in totalResults)
    {
        if (result.InnerHtml != null)
        {
            totalPages = result.InnerHtml;
            totalPages = totalPages.Substring(totalPages.LastIndexOf("f") + 1, 4);
            numOfResults = Convert.ToInt32(totalPages.Trim());
        }
    }
    var resultsSet = document.DocumentNode
                             .Descendants("div")
                              .Where(x => x.Attributes.Contains("class") &&
                                          x.Attributes["class"].Value.Contains("business-container-inner"));
    perPage = 0;
    foreach (var result in resultsSet)
        if (result.InnerHtml != null)
            perPage++;
    pageCount = (numOfResults / perPage) + 1;
}
calling:
Pages htmlDoc = new Pages(url);
Thread MyThread = new Thread(htmlDoc.pageResults);
MyThread.Start();
lblTotalRecords.Text = "Records Found : " + htmlDoc.numOfResults.ToString();
lblTotalRecords.Visible = true;
lblTotalPages.Text = "Pages Found : " + htmlDoc.pageCount.ToString();
lblTotalPages.Visible = true;
Before applying Thread all the values were setting properly but now all their values are set to 0.
 
     
     
     
    