private void ReportUserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (IsVisible == true)
     {
         ReportDataGrid.ItemsSource = CrawlerQueries.GetCrawlerDetails();
     }
 }
        private void btnStartSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                mCrawlDetail     = new CrawlDetail();
                this.DataContext = mCrawlDetail;

                string url = txtSearchUrl.Text;
                MyBrowser.Navigate(url);

                tbkCurrentStatus.Text = "Running";
                Thread th = new Thread(new ThreadStart(() =>
                {
                    WebCrawler spider = new WebCrawler(url, url, 100);
                    //spider.WebPageManager.WebPageContentHandler = [Delegate].Combine(spider.WebPageManager.WebPageContentHandler, New WebPageContentDelegate(AddressOf spider_WebPageContentHandler))
                    spider.WebPageManager.WebPageTaskCompleted = new WebPageContentDelegate(spider_WebPageContentHandler);
                    spider.Execute();
                    var lst = spider.WebPages.Values;
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        tbkCurrentStatus.Text = "Completed";

                        CrawlerDetail result = new CrawlerDetail();
                        result.ProjectName   = ProjectName;
                        result.CrawlDate     = DateAndTime.Now;
                        result.WebsiteUrl    = url;
                        result.TotalCrawled  = mCrawlDetail.TotalCrawled;
                        result.BrokenLinks   = mCrawlDetail.TotalBrokenLink;
                        CrawlerQueries.SaveCrawlerDetail(result);
                    }));
                }));
                th.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }
        }